首页 > 解决方案 > 我正在尝试使用 Clickatell 的 php(REST api)跟踪消息的传递状态

问题描述

在我的控制器中,我有

public function msgStatus(){
   $this->load->library('clickatell_rest');
   $this->clickatell_rest->getMsgStatus();
} 

clickatell 休息库类

  public function getMsgStatus(){   
    $msgId = "message ID here";

    $authToken = urlencode("token here");    

    $ch = curl_init();       
    curl_setopt($ch, CURLOPT_URL, "https://api.clickatell.com/rest/message/$msgId");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        "X-Version: 1",
        "Accept: application/json",
        "Authorization: Bearer $authToken"
    ));  
    $result = curl_exec ($ch);  
    print_r($result); exit();
    return $result;
}`

当我执行代码时,尽管我的凭据正确,但仍显示以下错误

{“错误”:{“代码”:“001”,“描述”:“身份验证失败”,“文档”:“ http://www.clickatell.com/help/apidocs/error/001.htm ”}}

我希望我的代码返回消息状态(即,如果消息已排队、失败、已交付给收件人等)

标签: codeignitercurlclickatell

解决方案


推荐阅读