请求方式
POST /whatsapp/authorize HTTP/1.1
Host: https://{your-domain}/api/open/v1
请求头
| 字段 | 类型 | 注释 |
| X-API-Key | string | 必填,API 密钥 |
通用请求参数
| 字段 | 类型 | 注释 |
| waba_id | string | 必填,WABA账户ID |
| phone_number_id | string | 可选,电话号码ID |
| code | string | 是,授权码(嵌入式注册时使用) |
| coexistence | string | 是否共享 (可选,true/false) |
请求数据:
{
“waba_id”: “10651111111111”,
“phone_number_id”: “1251911111111”,
“code”: “AQILSdEKXjF-RBtfzjjzO8Joxp5fGBYygeT_qef4pNoeUdnz8jdaF9qRCdOzPZFDpugjiFy1cSrI9VTsw4Y2hs5eUkiZUzxMNHZRmnr4KFtbUV8Zru3v7QXYWmj_UVgODTEIjqzs1ywzFvSdJGaxcp3cjZ8_9OKRJ-jmJe1PZz3L_J55pOlNGq1mYXaOX9MsyTrdZrLLIaxChiS-ZTN5mTARf8u0Ls79J2ewJsDOR8KFAI5RCRorHWbvixGPYJpWIr8pYrZt1-Ujui_pDXanN3VTp86FbkaUAszmx75xhUU1zNFZNtdhCBwpw5FMBWPNl8Ukkdb1sgLOT3Nw5DIA7g-tf3uUwo0ars6-wdS-w2Wg-AAbgZZkqga65yEVHB9bOK7wPb36DKmtG5v0p0nLHouRTlTp7xhJ6PheKR0YTQAZqOuMar1111111111111111111111111”,
“coexistence”:”true”
}
返回数据:
{
“code”: 1,
“data”: {
“id”: “1234567890123456”,
“name”: “My Business WhatsApp Account”,
“timezone_id”: “1”,
“message_template_namespace”: “ba30dd89_2ebd_41e4_b805_f2c05ae04cc9”,
“account_review_status”: “APPROVED”,
“business_verification_status”: “VERIFIED”,
“country”: “US”,
“ownership_type”: “SELF”,
“primary_business_location”: “US”
},
“msg”: “注册成功”
}
| 字段 | 类型 | 注释 |
| id | string | WABA 账户 ID |
| name | string | 账户名称 |
| timezone_id | string | 时区 ID |
| message_template_namespace | string | 消息模板命名空间 |
| account_review_status | string | 账户审核状态 |
| business_verification_status | string | 企业认证状态 |
| country | string | 国家代码 |
| ownership_type | string | 所有权类型 |
| primary_business_location | string | 主要业务所在地 |
WhatsApp Business API 授权注册:
- 请联系技术/销售 添加嵌入式授权的页面域名白名单,并获取APP_ID,CONFIGURATION_ID
- GRAPH_API_VERSION 为v25.0
- 页面嵌入授权请参考:实施 | 开发者文档 (facebook.com)
<!-- SDK loading -->
<script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js"></script><script>
// SDK initialization
window.fbAsyncInit = function() {
FB.init({
appId: '<APP_ID>', // your app ID goes here
autoLogAppEvents: true,
xfbml: true,
version: '<GRAPH_API_VERSION>' // Graph API version goes here
});
};
// Session logging message event listener
window.addEventListener('message', (event) => {
if (!event.origin.endsWith('facebook.com')) return;
try {
const data = JSON.parse(event.data);
if (data.type === 'WA_EMBEDDED_SIGNUP') {
console.log('message event: ', data); // remove after testing
// your code goes here
}
} catch {
console.log('message event: ', event.data); // remove after testing
// your code goes here
}
});
// Response callback
const fbLoginCallback = (response) => {
if (response.authResponse) {
const code = response.authResponse.code;
console.log('response: ', code); // remove after testing
// your code goes here
} else {
console.log('response: ', response); // remove after testing
// your code goes here
}
}
// Launch method and callback registration
const launchWhatsAppSignup = () => {
FB.login(fbLoginCallback, {
config_id: '<CONFIGURATION_ID>', // your configuration ID goes here
response_type: 'code',
override_default_response_type: true,
extras: {
setup: {},
}
});
}
</script><!-- Launch button --><button onclick="launchWhatsAppSignup()" style="background-color: #1877f2; border: 0; border-radius: 4px; color: #fff; cursor: pointer; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-weight: bold; height: 40px; padding: 0 24px;">Login with Facebook</button>
WhatsApp Business APP 共享:
- 请联系技术/销售 添加嵌入式授权的页面域名白名单,并获取APP_ID,BUSINESS_APP_SHARE_CONFIG_ID
- GRAPH_API_VERSION 为v25.0
- 接入 WhatsApp Business 应用用户(共存)请参考:实施 | 开发者文档 (facebook.com)
<!-- SDK loading -->
<script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js"></script><script>
// SDK initialization
window.fbAsyncInit = function() {
FB.init({
appId: '<APP_ID>', // your app ID goes here
autoLogAppEvents: true,
xfbml: true,
version: '<GRAPH_API_VERSION>' // Graph API version goes here
});
};
// Session logging message event listener
window.addEventListener('message', (event) => {
if (!event.origin.endsWith('facebook.com')) return;
try {
const data = JSON.parse(event.data);
if (data.type === 'WA_EMBEDDED_SIGNUP') {
console.log('message event: ', data); // remove after testing
// your code goes here
}
} catch {
console.log('message event: ', event.data); // remove after testing
// your code goes here
}
});
// Response callback
const fbLoginCallback = (response) => {
if (response.authResponse) {
const code = response.authResponse.code;
console.log('response: ', code); // remove after testing
// your code goes here
} else {
console.log('response: ', response); // remove after testing
// your code goes here
}
}
// Launch method and callback registration
const launchWhatsAppSignup = () => {
FB.login(fbLoginCallback, {
config_id: '<BUSINESS_APP_SHARE_CONFIG_ID>', // your configuration ID goes here
response_type: "code",
override_default_response_type: true,
extras: {
setup: {},
featureType: "whatsapp_business_app_onboarding",
version: "v4",
sessionInfoVersion: "3",
}
});
}
</script><!-- Launch button --><button onclick="launchWhatsAppSignup()" style="background-color: #1877f2; border: 0; border-radius: 4px; color: #fff; cursor: pointer; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-weight: bold; height: 40px; padding: 0 24px;">Login with Facebook</button>