Copy try{
$ch = curl_init('http://api.kodesms.com/sms/send');
curl_setopt($ch, CURLOPT_POST, 1);
$data = ['message'=>'Hello fred','recipient'=>'0240120250','sender_alias'=>'freddy'];
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER,
array("Content-Type: application/json ",
"ApiKey: {API KEY}",
"ApiSecret: {API SECRET}"
)
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$result = curl_exec($ch);
curl_close($ch);
}catch(\Exception $e){
trigger_error(sprintf(
'Curl failed with error #%d: %s',
$e->getCode(), $e->getMessage()),
E_USER_ERROR);
}
return $result;
}
Copy {
"error":0,
"message":"Message sent",
"messageId":"80f820e0-1531-11e6-961e-ef62622ea06c",
"charge":1
}
{
"error":1,
"message":"Failed sending sms"
}
{
"error":1,
"message":"Unauthorized access to service"
}