Send SMS in PHP using Way2sms API client
Way2SMS is a popular free sms service in India that offers users to send
SMS to mobile numbers using internet.The service is reliable and
delivers the SMS in few seconds but there is no public API available
for Way2sms. But Unofficially there is an API which communicates with Way2sms and most important thing is this API still works unlike many others.
//send SMS to patient
echo "Your messege has been sent will be deliever soon.";
$curl = curl_init();
$timeout = 30;
$result = array();
$ReciverMobile = '1234567890'; // Reciver Mobile Number
$uid = urlencode('1234567890'); //Way2sms Userid
$pwd = urlencode('1234567890'); //Way2sms login Password
$msg = 'YOUR MESSAGE ';
$autobalancer = 23;
// Setup for login
curl_setopt($curl, CURLOPT_URL, "http://site" . $autobalancer . ".way2sms.com/Login1.action");
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, "username=" . $uid . "&password=" . $pwd . "&button=Login");
curl_setopt($curl, CURLOPT_COOKIESESSION, 1);
curl_setopt($curl, CURLOPT_COOKIEFILE, "cookie_way2sms");
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_MAXREDIRS, 20);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5");
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($curl, CURLOPT_REFERER, "http://site" . $autobalancer . ".way2sms.com/");
$text = curl_exec($curl);
// Check if any error occured
if (curl_errno($curl))
return "access error : " . curl_error($curl);
// Check for proper login
$pos = stripos(curl_getinfo($curl, CURLINFO_EFFECTIVE_URL), "ebrdg.action");
if ($pos === "FALSE" || $pos == 0 || $pos == "")
return "invalid login";
// Check the message
if (trim($msg) == "" || strlen($msg) == 0)
return "invalid message";
// Take only the first 140 characters of the message
$msg = urlencode(substr($msg, 0, 140));
// Store the numbers from the string to an array
$pharr = explode(",", $ReciverMobile); //add dynamic mobile number here
// Set the home page from where we can send message
$refurl = curl_getinfo($curl, CURLINFO_EFFECTIVE_URL);
$newurl = str_replace("ebrdg.action?id=", "main.action?section=s&Token=", $refurl);
curl_setopt($curl, CURLOPT_URL, $newurl);
// Extract the token from the URL
$jstoken = substr($newurl, 50, -41);
//Go to the homepage
$text = curl_exec($curl);
// Send SMS to each number
foreach ($pharr as $p) {
// Check the mobile number
if (strlen($p) != 10 || !is_numeric($p) || strpos($p, ".") != false) {
$result[] = array('phone' => $p, 'msg' => urldecode($msg), 'result' => "invalid number");
continue;
}
$p = urlencode($p);
// Setup to send SMS
curl_setopt($curl, CURLOPT_URL, 'http://site' . $autobalancer . '.way2sms.com/smstoss.action');
curl_setopt($curl, CURLOPT_REFERER, curl_getinfo($curl, CURLINFO_EFFECTIVE_URL));
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, "ssaction=ss&Token=" . $jstoken . "&mobile=" . $p . "&message=" . $msg . "&button=Login");
$contents = curl_exec($curl);
//Check Message Status
$pos = strpos($contents, 'Message has been submitted successfully');
$res = ($pos !== false) ? true : false;
$result[] = array('phone' => $p, 'msg' => urldecode($msg), 'result' => $res);
}
// Logout
curl_setopt($curl, CURLOPT_URL, "http://site" . $autobalancer . ".way2sms.com/LogOut");
curl_setopt($curl, CURLOPT_REFERER, $refurl);
$text = curl_exec($curl);
curl_close($curl);
return $result;
//end sms
echo "Your messege has been sent will be deliever soon.";
$curl = curl_init();
$timeout = 30;
$result = array();
$ReciverMobile = '1234567890'; // Reciver Mobile Number
$uid = urlencode('1234567890'); //Way2sms Userid
$pwd = urlencode('1234567890'); //Way2sms login Password
$msg = 'YOUR MESSAGE ';
$autobalancer = 23;
// Setup for login
curl_setopt($curl, CURLOPT_URL, "http://site" . $autobalancer . ".way2sms.com/Login1.action");
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, "username=" . $uid . "&password=" . $pwd . "&button=Login");
curl_setopt($curl, CURLOPT_COOKIESESSION, 1);
curl_setopt($curl, CURLOPT_COOKIEFILE, "cookie_way2sms");
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_MAXREDIRS, 20);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5");
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($curl, CURLOPT_REFERER, "http://site" . $autobalancer . ".way2sms.com/");
$text = curl_exec($curl);
// Check if any error occured
if (curl_errno($curl))
return "access error : " . curl_error($curl);
// Check for proper login
$pos = stripos(curl_getinfo($curl, CURLINFO_EFFECTIVE_URL), "ebrdg.action");
if ($pos === "FALSE" || $pos == 0 || $pos == "")
return "invalid login";
// Check the message
if (trim($msg) == "" || strlen($msg) == 0)
return "invalid message";
// Take only the first 140 characters of the message
$msg = urlencode(substr($msg, 0, 140));
// Store the numbers from the string to an array
$pharr = explode(",", $ReciverMobile); //add dynamic mobile number here
// Set the home page from where we can send message
$refurl = curl_getinfo($curl, CURLINFO_EFFECTIVE_URL);
$newurl = str_replace("ebrdg.action?id=", "main.action?section=s&Token=", $refurl);
curl_setopt($curl, CURLOPT_URL, $newurl);
// Extract the token from the URL
$jstoken = substr($newurl, 50, -41);
//Go to the homepage
$text = curl_exec($curl);
// Send SMS to each number
foreach ($pharr as $p) {
// Check the mobile number
if (strlen($p) != 10 || !is_numeric($p) || strpos($p, ".") != false) {
$result[] = array('phone' => $p, 'msg' => urldecode($msg), 'result' => "invalid number");
continue;
}
$p = urlencode($p);
// Setup to send SMS
curl_setopt($curl, CURLOPT_URL, 'http://site' . $autobalancer . '.way2sms.com/smstoss.action');
curl_setopt($curl, CURLOPT_REFERER, curl_getinfo($curl, CURLINFO_EFFECTIVE_URL));
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, "ssaction=ss&Token=" . $jstoken . "&mobile=" . $p . "&message=" . $msg . "&button=Login");
$contents = curl_exec($curl);
//Check Message Status
$pos = strpos($contents, 'Message has been submitted successfully');
$res = ($pos !== false) ? true : false;
$result[] = array('phone' => $p, 'msg' => urldecode($msg), 'result' => $res);
}
// Logout
curl_setopt($curl, CURLOPT_URL, "http://site" . $autobalancer . ".way2sms.com/LogOut");
curl_setopt($curl, CURLOPT_REFERER, $refurl);
$text = curl_exec($curl);
curl_close($curl);
return $result;
//end sms
Good job harshit
ReplyDelete-jk
Super work buddy
ReplyDeleteThanks Anusha
ReplyDeleteI am expecting more interesting topics from you. And this was nice content and definitely it will be useful for many people.
ReplyDeleteDigital Mobile Marketing
SMS API
SMS Marketing
Thanks Rosy....
DeleteThis comment has been removed by the author.
ReplyDeletewaoo nice post regarding "Sed SMS in PHP using Way2sms API client"
ReplyDeleteThanks,
Gold Tips Free Trial
such a excellent and wonderful post, thanks for sharing with us.
ReplyDeleteNIOS Admission on Demand
Thanks...
Deletenot working
ReplyDeleteHello Arijit,
DeletePlease let me know where you get the issue using it..?
aha badaa ho gya ab developer! great work keep it up
ReplyDeleteThanks....
DeleteBulk SMS is utilized as promotional SMS and Transactional for SMS marketing. Our bulk SMS marketing solution helps you to send cheap bulk promotional SMS service provider in India. It's least expensive marketing solution to reach achieve imminent clients. MAXWELL Communication furnishes bulk SMS service with NDNC filter, so you don't have any lawful issues with NDNC Registry.Best Bulk Sms Provider In India
ReplyDeleteYes, If you want to send large number of message in single click then this service is beneficial for you. You can easily integrate Bulk SMS API into your software and send bulk sms in few min.
ReplyDeleteThis article turned out to be very gainful for me. I was searching for this all over the internet. You made my search easy, and I genuinely admire you for that. Certainly, this might be beneficial for many other learners as well. Keep sharing this tremendous articles and continue updating us.
ReplyDeleteWebsite Design Agency | Website design company
how it works??
ReplyDeletehelp me pls.
asshole code doesnt works..!
ReplyDeleteWhy are u doing this!!!
ReplyDeleteThanks for sharing this information. The most interesting part is that it provides all the required API tests and commands. This will take you only a few seconds to download and install it in your existing application or software.
ReplyDeletesms api php
php sms gateway integration
You are welcome
DeleteThanks for sharing the valuable information with us.These are really great and useful in all aspects,appreciated!
ReplyDeletePHP-MySQL Interview Questions
Top 10 PHP Interview Questions
PHP Functions asked in Interview
You are welcome
ReplyDeleteHey Nice Blog!! Thanks For Sharing!!!Wonderful blog & good post.Its really helpful for me, waiting for a more new post. Keep Blogging!
ReplyDeletebest java training in coimbatore
php training in coimbatore
best php training institutes in coimbatore
Hi, Thanks for sharing the useful source code in PHP to send SMS using Way2SMS API Client.
ReplyDeleteCustom Web Application Development Company in Coimbatore
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.
ReplyDeleteStart Your own Software Company Without Developing any Software. Our Products Your Brand. Get Whitelabled softwares and put Your own Logo, Your Website, Your contact No. on the software and resale in market. Earn much as you can. Download Demo Softwares from Call For More info: +91-9876236634
ReplyDeleteyour site is fantastic..please do visit our site
ReplyDeleteJava Software Development Service
It is amazing and wonderful to visit your site. The most interesting part is that it provides all the required API tests and commands.
ReplyDeleteBulk SMS API
Bulk SMS API India
This blog is so informative for providing a valuable information about me.
ReplyDeleteSMS API PHP Integration
Thanks for sharing this blog.
ReplyDeleteBulk SMS API
Nice article. It's very helpful to me. Thank you for share with us. Can you please check my article create simple blood donation management system in PHP code.
ReplyDeleteThank you so much for this useful information. looking more from your side to update us on more updates and advancements
ReplyDeleteUFC 248 Adesanya vs Romero Live Streaming Online
ReplyDeletehttps://issuu.com/livestream675/docs/ufc_248_adesanya_vs_romero_live_streaming_online.d
https://issuu.com/livestream675/docs/ufc_248_adesanya_vs_romero_live_streaming_online.d
https://medium.com/@livestream675/ufc-248-adesanya-vs-romero-live-streaming-online-2020-6ba41c15df6d?sk=f6ad974e1a1d26a571935800a5ab8f63
https://medium.com/@livestream675/ufc-248-adesanya-vs-romero-live-streaming-online-2020-6ba41c15df6d?sk=f6ad974e1a1d26a571935800a5ab8f63
Boxing Scott Quigg VS Jono Carroll Live Streaming Online
https://issuu.com/livestream675/docs/boxing_scott_quigg_vs_jono_carroll_live_streaming_
https://issuu.com/livestream675/docs/boxing_scott_quigg_vs_jono_carroll_live_streaming_
https://medium.com/@livestream675/boxing-scott-quigg-vs-jono-carroll-live-streaming-online-a02e14c14ee6?sk=a579d95263d0595cd20e2af02ab16711
https://medium.com/@livestream675/boxing-scott-quigg-vs-jono-carroll-live-streaming-online-a02e14c14ee6?sk=a579d95263d0595cd20e2af02ab16711
NASCAR Ticketguardian 500 Live Streaming Online
https://issuu.com/livestream675/docs/nascar_ticketguardian_500_live_streaming_online.do
https://issuu.com/livestream675/docs/nascar_ticketguardian_500_live_streaming_online.do
Nice information, thanks for sharing with us Android Bulk SMS Sender.
ReplyDeleteRare is a page like yours that uses the social platform to its true potential. I like that you have good attention to detail and are always making better posts. I am following your page for a long time and I have seen your style getting better and better as time passes. Best WordPress hosting
ReplyDeleteSi Contact Form Plugin using for captcha to setup contact form in get it proper way it make properly
ReplyDeleteWoocommerce Floating Cart setup in woocommerce side cart in your ecommerce website
ReplyDeletefast secure contact form for setup contact form with captcha and secure in your wordpress site
ReplyDeleteFast Secure Contact Form is replace with old si contact form plugin to using with wordpress as contact form plguin
ReplyDelete