idalatob
09-10-2010, 08:33 AM
Hi there,
I thought a lot of you guys might find this interesting, its an API to send SMS's from a browser etc. Just keep in mind that you have to set up an account with panaceamobile @ www.panaceamobile.com (http://www.panaceamobile.com)! But sending a sms with them is generally a whole lot cheaper anyway!
Enjoy the API:
<?php
function send_message($username, $password, $from, $to, $message, $track_delivery = 0) {
$url = "http://api.panaceamobile.com/sendsms?1";
$data = array(
"to" => $to,
"from" => $from,
"dlr-mask" => $track_delivery,
"text" => $message,
"username" => $username,
"password" => $password
);
foreach($data as $key => $val) {
$data[$key] = urlencode($val);
}
$str = $url;
foreach($data as $key => $val) {
$str .= "&{$key}={$val}";
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $str);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($ch);
if($res !== FALSE) {
if(
(strpos($res, "Accepted") === FALSE) &&
(strpos($res, "Queued") === FALSE) &&
(strpos($res, "Sent") === FALSE)
)
return false;
return true;
}
return false;
}
$to = "44325321234";
$from = "4432532021";
if(send_message("myusername", "mypassword", $to, $from, "Hello Messaging!", 1)) {
echo "Message Sent!";
} else {
echo "Message Failed!";
}
?>
I thought a lot of you guys might find this interesting, its an API to send SMS's from a browser etc. Just keep in mind that you have to set up an account with panaceamobile @ www.panaceamobile.com (http://www.panaceamobile.com)! But sending a sms with them is generally a whole lot cheaper anyway!
Enjoy the API:
<?php
function send_message($username, $password, $from, $to, $message, $track_delivery = 0) {
$url = "http://api.panaceamobile.com/sendsms?1";
$data = array(
"to" => $to,
"from" => $from,
"dlr-mask" => $track_delivery,
"text" => $message,
"username" => $username,
"password" => $password
);
foreach($data as $key => $val) {
$data[$key] = urlencode($val);
}
$str = $url;
foreach($data as $key => $val) {
$str .= "&{$key}={$val}";
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $str);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($ch);
if($res !== FALSE) {
if(
(strpos($res, "Accepted") === FALSE) &&
(strpos($res, "Queued") === FALSE) &&
(strpos($res, "Sent") === FALSE)
)
return false;
return true;
}
return false;
}
$to = "44325321234";
$from = "4432532021";
if(send_message("myusername", "mypassword", $to, $from, "Hello Messaging!", 1)) {
echo "Message Sent!";
} else {
echo "Message Failed!";
}
?>