...

View Full Version : concatenate a long sms before sending to API



jerry4all
02-17-2012, 01:20 PM
Hi...I'm using Curl to connect to an sms API.however I just learned that to send a message more that 160 characters need concatenating. how do I go about this in my code thanks....Here's a copy of my code..



$phone = substr($phone, 0, strlen($phone)-1);

$message = mysql_real_escape_string($_POST['message']);
$sender = $_POST['sender'];
$url1 = "../sms/send_sms.php?";
//initialize the request variable

$request = "";

$param["?username"] = "";

$param["password"] = "";
//this is the message that we want to send
$param["message"] = $message;
//these are the recipients of the message
$param["mobile"] = $phone;
//this is our sender
$param["sender"] = $sender;
//traverse through each member of the param array
foreach($param as $key=>$val){
//we have to urlencode the values
$request.= $key."=".urlencode($val);
//append the ampersand (&) sign after each paramter/value pair
$request.= "&";
}
//remove the final ampersand sign from the request
$request = substr($request, 0, strlen($request)-1);


$url = "http://sms.bulksms.com/bulksms/bulksms.php";



$ch = curl_init();

//initialize curl handle

curl_setopt($ch, CURLOPT_URL, $url.$request);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

//set the url
date_default_timezone_set('Africa/Lagos');
$time= date('H:i:s');
$today = date("Y-m-d");

//return as a variable



//set POST method


//set the POST variables

$response = curl_exec($ch);
//close the curl handle
if( $response == 1801){
$response = "Message sent successfully";}
elseif ($response == 1802){
$response = "Invalid username";}
elseif ($response == 1803){
$response = "Invalid Password";}
elseif ($response == 1809){
$response = "Message Empty";}
else{$response = "Message not sent";}

$sql= "INSERT INTO sent VALUES('','$today','$time','$message','$response','$phone')";
$result= mysql_query($sql) or die(mysql_error());
//run the whole process and return the response

curl_close($ch);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum