duanni5726 2016-02-03 00:08
浏览 31
已采纳

在PHP中使用Clickatell的REST api

I'm trying to programmatically send SMS messages in my php code using the REST api from Clickatell. I've got this code:

<?php
$message = "Test Message";
$numbers = array("1**********","1**********");
$data = json_encode(array("text"=>$message,"to"=>$numbers));
$authToken = "none of your buisness";

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,            "https://api.clickatell.com/rest/message");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST,           1);
curl_setopt($ch, CURLOPT_POSTFIELDS,     $data);
curl_setopt($ch, CURLOPT_HTTPHEADER,     array(
    "X-Version: 1",
    "Content-Type: application/json",
    "Accept: application/json",
    "Authorization: Bearer $authToken"
));

$result = curl_exec ($ch);

echo $result
?>

It all seems to work, because this is the result I'm getting:

{
"data": {
    "message":[
        {
            "accepted":true,
            "to":"1**********",
            "apiMessageId":"e895a0e68089d76fa05f41046a186a70"
        }
    ]
}
}

However, I haven't received the message on my device. Is this something I can debug or is it beyond me?

  • 写回答

1条回答 默认 最新

  • dongyukui8330 2016-02-03 07:08
    关注

    The apiMessageId (tracking code) that you got back does not confirm actual delivery - it simply means the message has been accepted for processing.

    It looks like you sent a message to the USA, with an account that does not have access to the USA. You can contact the support team to assist you with setting up/getting the correct account that allows USA delivery.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Marscode IDE 如何预览新建的 HTML 文件
  • ¥15 K8S部署二进制集群过程中calico一直报错
  • ¥15 java python或者任何一种编程语言复刻一个网页
  • ¥20 如何通过代码传输视频到亚马逊平台
  • ¥15 php查询mysql数据库并显示至下拉列表中
  • ¥15 freertos下使用外部中断失效
  • ¥15 输入的char字符转为int类型,不是对应的ascall码,如何才能使之转换为对应ascall码?或者使输入的char字符可以正常与其他字符比较?
  • ¥15 devserver配置完 启动服务 无法访问static上的资源
  • ¥15 解决websocket跟c#客户端通信
  • ¥30 Python调用dll文件输出Nan重置dll状态