0

In my controller i have

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

clickatell rest library class

  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;
}`

when i execute the code the following error displays though my credentials are correct

{"error":{"code":"001","description":"Authentication failed","documentation":"http://www.clickatell.com/help/apidocs/error/001.htm"}}

i expect my code to return a message status (i.e if the message is queued, failed,delivered to recepient, etc)

Pradeep
  • 9,667
  • 13
  • 27
  • 34
sebake
  • 9
  • 4
  • Are you sure you’re supposed to urlencode the token value yourself? – CBroe May 14 '18 at 09:54
  • even when i omit the the urlencode it gives me the same results – sebake May 14 '18 at 09:57
  • Well then something else must be wrong ... hard to tell what exactly though, when even the link to the documentation from the error message leads only to a 404. – CBroe May 14 '18 at 09:58
  • definitely i just dont know what i am missing in my code – sebake May 14 '18 at 10:04
  • Can you point us to the proper URL for the API documentation? – CBroe May 14 '18 at 10:04
  • https://archive.clickatell.com/developers/api-docs/list-of-error-codes-rest/ – sebake May 14 '18 at 10:07
  • Example under https://archive.clickatell.com/developers/api-docs/using-the-rest-api-rest/ also sends a `Content-Type` header (not sure whether that should make a difference regarding authentication though.) – CBroe May 14 '18 at 10:18

0 Answers0