Skip to main content

Hi Ringcentral,


I use Ring central SMS API in PHP. I got message "Access token corrupted" when I try to send SMS. I searched for this but not found any solution.


My application is in under development mode.


Here is my code:

function send_sms(){

$credential = get_access_token();
$access_token = refresh_access_token($credential['refresh_token']);

if(isset($access_token['error']) && $access_token['error']!=''){
echo $access_token['error_description'];
}
else{

$url = "https://platform.devtest.ringcentral.com/restapi/v1.0/account/177248004/extension/101/sms";
$header = array("Accept: application/json;","Authorization: Bearer ".$access_token['access_token'].";","Content Type: application/json;");
$sms_data = json_encode(array("from"=>array("phoneNumber"=> RC_FROM_PHONE_NUMBER),"to"=>array(array("phoneNumber"=> $_POST['phone'])),"text"=>trim($_POST['message'])));

$objCCurl = new CCurl();
$data = $objCCurl->curl_request($url,'POST',$sms_data,$header,false,false);

if(isset($data['errorCode']) && $data['errorCode']!=''){

$err = $data['errorCode'];
if(isset($data['message']) && $data['message']!=''){
$err .= ' - '.$data['message'];
}
}
else{
//success
}


}


}


OUTPUT :

{ "errorCode" : "TokenInvalid", "message" : "Access token corrupted", "errors" : [ { "errorCode" : "OAU-129", "message" : "Access token corrupted" } ] }


Please let me know how to resolve this error.


Thanks in advance.







Please don't append a semicolon to the token and try again.
"Authorization: Bearer ".$access_token['access_token'].";"
==>
"Authorization: Bearer ".$access_token['access_token']

As pointed, a small typo mistakes in your code will lead to different type of issue or exceptions.

Make sure you check all these in your code before querying in forum and remove it


Reply