【问题标题】:Text multiple numbers using clickatell php gateway API使用clickatell php网关API发送多个数字
【发布时间】:2015-06-07 23:24:09
【问题描述】:

我目前正在使用 clickatell 使用 FOR 方法向单个号码发送消息

for($i = 0;$i < count($textrecievers); $i++){
$url = 'http://api.clickatell.com/http/sendmsg?user=user&password=****&api_id=00000&to=1'.$textrecievers[$i].'&text='.$msgtxt.'&mo=1&from='.$_SESSION['routing'];

$ret = file($url);
            }

问题是如果其中一个失败,我无法将其报告给数据库,因为我无法使用此方法

$send = explode(":",$ret[0]);

                if ($send[0] == "ID") {
echo 'OK';
}

有什么方法可以像这样将其作为批量文本发送:

$to = array('1111111111','2222222222','3333333333')

然后把它放在usr中

 $url = 'http://api.clickatell.com/http/sendmsg?user=user&password=****&api_id=00000&to='.$to.'&text='.$msgtxt.'&mo=1&from='.$_SESSION['routing'];

所以它会在 1 go 时将它发送到数组中的所有数字,所以我可以将它报告为成功与否。

【问题讨论】:

    标签: php sms clickatell


    【解决方案1】:

    不确定我是否正确理解了您的问题,但您可以像这样用逗号分隔手机号码:

    http://api.clickatell.com/http/sendmsg?api_id=....&to=123456789,123456789,123456789,123456789,123456789,123456789&text=....

    为了安全起见,您可以使用 HTTP GET 将大约 300 个数字用逗号分隔(如果使用 POST 则更多,例如 800 - 取决于您等待超时的时间)。

    //逗号分隔并添加前导1作为国家代码 $comma_separated = implode(",1", $YourArray);

    您将收到每条消息(或错误)的跟踪消息 ID,因此您可以跟踪是否有任何特定号码被拒绝。

    这是否回答了您的问题?

    【讨论】:

      【解决方案2】:

      不幸的是,您不能再一次调用中使用http API 发送到多个号码(尽管您可以循环调用 API 多次的号码)

      您可以通过一个 HTTPS 向单个手机发送消息 请求。

      另一种选择是使用REST API 发送到多个号码(根据他们的文档,每次呼叫最多 200 个):https://www.clickatell.com/developers/api-documentation/rest-api-send-message/

      【讨论】:

        猜你喜欢
        • 2013-08-16
        • 1970-01-01
        • 1970-01-01
        • 2013-01-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-08-22
        相关资源
        最近更新 更多