PHP Code for Sending free SMS through your way2sms account…



Sending free SMS through way2sms in PHP


<?php
function send_sms($userID$userPWD$recerverNO$message)
{
if (!
function_exists(‘curl_init’)) {
echo 
“Error : Curl library not installed”;
return 
FALSE;
}
$message_urlencode rawurlencode($message);
if (
strlen($message) > 140) {$message substr($message0139);
}
$cookie_file_path “./cookie.txt”;$temp_file        “./temporary.txt”;$user_agent      “Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36”;
// LOGIN TO WAY2SMS
$url        “http://site24.way2sms.com/content/Login1.action”;$parameters = array(“username” => $userID,“password” => $userPWD,“button” => “Login”);
$ch curl_init();curl_setopt($chCURLOPT_URL$url);curl_setopt($chCURLOPT_POSTcount($parameters));curl_setopt($chCURLOPT_POSTFIELDS$parameters);curl_setopt($chCURLOPT_HEADERTRUE);curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);curl_setopt($chCURLOPT_COOKIEJAR$cookie_file_path);curl_setopt($chCURLOPT_COOKIEFILE$cookie_file_path);curl_setopt($chCURLOPT_FOLLOWLOCATIONTRUE);curl_setopt($chCURLOPT_USERAGENT$user_agent);curl_setopt($chCURLOPT_NOBODYFALSE);$result curl_exec($ch);curl_close($ch);
// SAVE LOGOUT URL
file_put_contents($temp_file$result);$result     “”;$logout_url “”;$file       fopen($temp_file“r”);$line       “”;$cond       TRUE;
while (
$cond == TRUE) {$line fgets($file);
if (
$line === FALSE) { // EOF$cond FALSE;
} else {
$pos strpos($line‘ window.location=”‘);
if (
$pos === FALSE) {$line “”;
} else { 
// URL FOUND$cond       FALSE;$logout_url substr($line, –25);$logout_url substr($logout_url021);
}
}
}
fclose($file);
// SAVE SESSION ID
$file fopen($cookie_file_path“r”);$line “”;$cond TRUE;
while (
$cond == TRUE) {$line fgets($file);
if (
$line === FALSE) { // EOF$cond FALSE;
} else {
$pos strpos($line“JSESSIONID”);
if (
$pos === FALSE) {$line “”;
} else { 
// SESSION ID FOUND$cond FALSE;$id   substr($line$pos 15);
}
}
}
fclose($file);
// SEND SMS
$url        “http://site24.way2sms.com/smstoss.action?Token=” $id;$parameters = array(“button” => “Send SMS”,“mobile” => $recerverNO,“message” => $message);
$ch curl_init();curl_setopt($chCURLOPT_URL$url);curl_setopt($chCURLOPT_POSTcount($parameters));curl_setopt($chCURLOPT_POSTFIELDS$parameters);curl_setopt($chCURLOPT_HEADERTRUE);curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);curl_setopt($chCURLOPT_COOKIEJAR$cookie_file_path);curl_setopt($chCURLOPT_COOKIEFILE$cookie_file_path);curl_setopt($chCURLOPT_FOLLOWLOCATIONTRUE);curl_setopt($chCURLOPT_USERAGENT$user_agent);curl_setopt($chCURLOPT_NOBODYFALSE);$result curl_exec($ch);curl_close($ch);
// LOGOUT WAY2SMS
$url “site24.way2sms.com/” $logout_url;
$ch curl_init();curl_setopt($chCURLOPT_URL$url);curl_setopt($chCURLOPT_HEADERTRUE);curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);curl_setopt($chCURLOPT_COOKIEJAR$cookie_file_path);curl_setopt($chCURLOPT_COOKIEFILE$cookie_file_path);curl_setopt($chCURLOPT_FOLLOWLOCATIONTRUE);curl_setopt($chCURLOPT_USERAGENT$user_agent);curl_setopt($chCURLOPT_NOBODYFALSE);$result curl_exec($ch);curl_close($ch);
// DELETE TEMP FILES
unlink($cookie_file_path);unlink($temp_file);
return TRUE;
}
?>

Comments

  1. This blog is so informative for providing a valuable information about sending bulk sms api php code. Thanks for sharing.

    ReplyDelete
  2. This site is help full for every person and easily get money through bitcoin atm card .please visit this site for bitcoin atm card ranking.you can change any money into another currency in any where in the world.

    ReplyDelete
  3. In order to stay connected to the world around you, mobiles were invented and to use it you need to keep recharging it with balance. The basic concept of top up phone with bitcoin money is quite different from the paper money.

    ReplyDelete
  4. Nice site....Please refer this site also Our vision success!Training are focused on perfect improvement of technical skills for Freshers and working professional. Our Training classes are sure to help the trainee with COMPLETE PRACTICAL TRAINING and Real time methodologies
    Dot Net Training Center in Chennai
    Selenium Training Institute in Chennai
    Testing Courses in Chennai
    Java Training Institute in Chennai
    PHP Course in Chennai

    ReplyDelete
  5. Our Ready php code/ script will help you to save time and efforts at a large level. Your enterprise/organization's php application can be easily integrated with our services. However, we provide ready to use bulk SMS API PHP code that helpfuls to send various information to your user's mobile.

    ReplyDelete
  6. A lot of student takes higher education but ironic thing is that you may find out some student don't know even HTTP Full Form & PHP Full Form of Computer. Do practical with your friend.

    ReplyDelete
  7. Nice blog. MsgClub SMS API PHP send a text message directly from your own software, website or application which developed using php code is now gets possible. Your search for sending information from a reliable and robust application will get end here because MsgClub is helping api users.
    Bulk sms

    ReplyDelete

Post a Comment

Popular Posts