...

Send SMS code

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!";
}


?>

idalatob
09-10-2010, 08:34 AM
Quite useful if you are implementing a solution with a client who needs SMS support! :-D

textmedia
03-27-2011, 05:17 AM
Nice share i will try this an see how it works............

kelsie
03-27-2011, 06:51 AM
Hmm this could be useful, thanks for sharing!

12k
01-14-2012, 05:20 PM
I always prefer just simply sending it using a smtp. Only downside is some phone carriers consider it as a data charge even though its a text message. Its free for you to send texts anyways :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum