RESTful API Example Code [PHP]

$postData = array();
$postData['cid'] = 'Test'; //Caller ID
$postData['to'] = ''; //Destination number
$postData['msg'] = 'This is a test message'; //Message test
$postData['user'] = ''; //TT Username
$postData['pass'] = ''; //TT Password
$postData['service'] = '1234'; //Service ID - can be obtained from portal.neural.net.au under 'Service Information'
$postData['confirm'] = '1'; //Send postback on completion (1 = yes, 0 = no)
$postData['action'] = 'sendsms';


$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, "Neural SMS PHP Example Code");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_VERBOSE, false);
curl_setopt($ch, CURLOPT_URL, "https://sms.neural.net.au:15000/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
$result = explode('|',curl_exec($ch));
curl_close($ch);

if($result[0] == 'queued'){
     echo 'Message queued for sending with unique ID ' . $result[1];
}elseif($result[0] == 'error'){
     echo 'Sending failed - error code ' . $result[1];
}elseif(!$result[0]){
     echo 'No response received - communication issue';
}else{
     echo 'Unexpected response received: ' . $result[0];
};

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk