如何在 SMS 状态从“排队"更改为“已发送"时收到通知? [英] How to get notified when SMS Status changes from 'Queued' to 'Sent'?

查看:32
本文介绍了如何在 SMS 状态从“排队"更改为“已发送"时收到通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我正在尝试学习 Twilio API.
当我 [通过 php 发送 SMS][1] 脚本时.. twilio 返回一个 status = 'queued' 的响应对象.现在我想在状态更改为已发送"时收到通知.这可以用 Twilio 吗???如果是,那么任何机构都可以建议我如何实施他的.

以及如何添加StatusCallback"网址

Hello,
I am trying to learn Twilio API.
When I [send SMS through php][1] script.. twilio returns a response object with status = 'queued'. Now I want to get notified when the status changes to 'sent'. Is this possible with Twilio??? and if yes then could any body advise me on how to implement his.

And how to add 'StatusCallback' url

$sms = $client->account->sms_messages->create(
            // the number we are sending from, must be a valid Twilio number
            "000-000-0000", 

            // the number we are sending to - Any phone number
            "0000000000",

            // the sms body
            "Hey Friend, Monkey Party at 6PM. Bring Bananas!"
        );

推荐答案

您正在寻找 StatusCallback 的正确轨道.使用 Twilio PHP 库时,可以使用数组作为最后一个参数来设置任何可选参数.

You're on the right track looking to the StatusCallback. When using the Twilio PHP Library any optional parameters can be set using an array as the last argument.

<?php
$sms = $client->account->sms_messages->create(
  "1235551234", 
  "1235554321",
  "Hey Friend, Monkey Party at 6PM. Bring Bananas!",
  array('StatusCallback' => 'http://example.com/sms/status.php')
);

当消息被发送时(或者如果它失败),数据将被传递到 StatusCallback url.

When the message is sent (or if it fails) the data will be passed to the StatusCallback url.

这篇关于如何在 SMS 状态从“排队"更改为“已发送"时收到通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆