Es fácil y rápido y recibirás un bono de 5 créditos sin costo.
<?php
$username = 'your_username';
$password = 'your_password';
$msisdn = '44123123123';
$message = 'This is a test SMS';
$url = 'http://bulksms.com.es/eapi/submission/send_sms/2/2.0';
$port = 80;
/*
* We recommend that you use port 5567 instead of port 80, but your
* firewall will probably block access to this port (see FAQ for more
* details):
* $port = 5567;
*/
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_PORT, $port);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$post_body = '';
$post_fields = array(
username => $username,
password => $password,
message => $message,
msisdn => $msisdn
);
foreach($post_fields as $key=>$value) {
$post_body .= urlencode($key).'='.urlencode($value).'&';
}
$post_body = rtrim($post_body,'&');
# Do not supply $post_fields directly as an argument to CURLOPT_POSTFIELDS,
# despite what the PHP documentation suggests: cUrl will turn it into in a
# multipart formpost, which is not supported:
curl_setopt ($ch, CURLOPT_POSTFIELDS, $post_body);
$response_string = curl_exec($ch);
$curl_info = curl_getinfo($ch);
if ($response_string == FALSE) {
print "cURL error: ".curl_error($ch)."\n";
} elseif ($curl_info['http_code'] != 200) {
print "Error: non-200 HTTP status code: ".$curl_info['http_code']."\n";
}
else {
print "Response from server:$response_string\n";
$result = split('\|', $response_string);
if (count($result) != 3) {
print "Error: could not parse valid return data from server.\n".count($result);
} else {
if ($result[0] == '0') {
print "Message sent - batch ID $result[2]\n";
}
else {
print "Error sending: status code [$result[0]] description [$result[1]]\n";
}
}
}
curl_close($ch);
?>