我已使用Twilio api发送通知消息。消息正在正确发送。
$notification = $client
->notify->services($serviceSid)
->notifications->create([
"toBinding" => [
'{"binding_type":"sms", "address":"+971444444444"}',
'{"binding_type":"sms", "address":"+971444444445"}'
],
'body' => 'Test message 8'
]);
请求的响应是201并返回以'NT'
开头的sid。如何跟踪此消息的状态?
答案 0 :(得分:1)
应该是这样的:
PHP:
$notification = $client
->notify->services($serviceSid)
->notifications->create([
"toBinding" => [
'{"binding_type":"sms", "address":"+971444444444"}',
'{"binding_type":"sms", "address":"+971444444445"}'
],
'body' => 'Test message 8'
'sms' => ['status_callback' => 'https://youcallbackurl.com']
]);
或Javascript
const service = twilio.notify.services(notifyId);
const bindings = numbers.map(number => {
return JSON.stringify({
binding_type: 'sms',
address: number,
});
});
service.notifications.create({
toBinding: bindings,
body: message,
sms: {
status_callback: 'https://youcallbackurl.com'
}
})
答案 1 :(得分:0)
twilio有一个callback
状态webhook,您需要对其进行配置以跟踪短信的发送状态
$notification = $client
->notify->services($serviceSid)
->notifications->create([
"toBinding" => [
'{"binding_type":"sms", "address":"+971444444444"}',
'{"binding_type":"sms", "address":"+971444444445"}'
],
'body' => 'Test message 8'
'statusCallback' => "your public end point to track sms delivery status"
]);
查看更多here
答案 2 :(得分:0)
使用PHP通过Twilio发送多个SMS的步骤
MESSAGING SERVICE SID
:$sid = 'ACb2f967a907520b85b4eba3e8151d0040'; //twilio service SID
$token = '03e066de1020f3a87cec37bb89f56dea'; //twilio Account SID
$serviceSid = 'IS4220abf29ae4169992b8db5fc2668b10'; //Notify service SID
$client = new Client($sid, $token);
$rs = $client->notify->services($serviceSid)->notifications->create([
"toBinding" => [
'{"binding_type":"sms", "address":"+919999999999"}',
'{"binding_type":"sms", "address":"+919999999999"}'
],
'body' => 'Test message 8',
'statusCallback' => "your public end point to track sms delivery status"
]);