Here is an example function for calling the JSON API with PHP
PHP
Calling JSON API
-------------------------------------------------------------------------------------------------------------------------------
array(
"-uid"=>"[USERNAME]",
"-pwd"=>"[PASSWORD]",
"-action"=>"[FUNCTION]"
),
"body" => array(
"msisdn"=> array(
"447771112222",
"447123456789"),
"msg"=>"[MESSAGE]",
"orig"=> "[ORIGINATOR]"
)
);
$data = array("campaign" => $data_array);
// And then encoded as a json string
$data_string = json_encode($data);
$ch=curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json', 'Content-Length: ' . strlen($data_string)));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Required for SSL
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$result = curl_exec($ch);
curl_close($ch);
// print out response
print_r($result);
?>