<?php
//==================================== Simple PHP code sample ==========================================//
/*
* This example requires allow_url_fopen to be enabled in php.ini. If it is not enabled, file_get_contents()
* will return an empty result.
*
* Please see the FAQ regarding HTTPS (port 443) and HTTP (port 80/5567)
*
* Please note that this is only for illustrative purposes, we strongly recommend that you use our comprehensive example
*/
$url = 'EAPI_URL/submission/send_sms/2/2.0';
$msisdn = '44123123123';
$data = 'username=your_username&password=your_password&message='.urlencode('Testing SMS').'&msisdn='.urlencode($msisdn);
$response = do_post_request($url, $data);
print $response;
function do_post_request($url, $data, $optional_headers = 'Content-type:application/x-www-form-urlencoded') {
$params = array('http' => array(
'method' => 'POST',
'content' => $data,
));
if ($optional_headers !== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
$response = @file_get_contents($url, false, $ctx);
if ($response === false) {
print "Problem reading data from $url, No status returned\n";
}
return $response;
}
?>