php code to send sms via website

Introduction:

Now a days web developers are using SMS for verification purpose, because they think it is the most trusted method for verification. We know that SMS is not free, but some companies are providing free SMS credit, by using this free credits we can send free SMS. Companies like Way2sms are not providing any official API to send SMS but some other companies will give you SMS API with Free Credits. Today I am going to write a tutorial that will helps you to integrate a website or localhost PHP page with SMS API and send SMS through it.

How Integrate SMS API With Your Website or Localhost PHP Page:

It is very easy to integrate SMS API with your PHP Page. Before you start you have to create a free Account with : Fast2Sms. After you create A/c with the website, Follow the steps that give below.
  • Log-in to the Dashboard of Free2Sms A/c and go to API Section and Grab your Access Token from them.
free2sms api
  • Grab your free Access token from the dashboard by click the "Token ID" and download the ready made PHP script from the below link address.
  • Download Latest Ready Made API Integrated PHP Script.
  • Upload the script to your web server using FTP. If you are using localhost with Xampp then move the file to Htdocs folder.
  • Now open the "sendsms.php" Page and edit your "Token ID" by replacing the "Your Token Here" Text.
<?php
$token = 'Your Token Here';
$mobile = mysql_real_escape_string($_POST['phone']);
$msg = mysql_real_escape_string($_POST['message']);
$site = 'Your Site Address Here';
$url = "http://api.fast2sms.com/sms.php?token=".$token."&mob=".$mobile."&mess=".$msg."&sender=".$site."&route=0";
$homepage = file_get_contents($url);
if($homepage)
{
  echo "Message Send Compleated...";
}
else{
  echo "Something Went Wrong...";
}
?>
  • The above code is the primary code. After user click the submit button, The form will post the phone number and message to the sendsms.php. The $mobile and $msg will receive it and pass the value to the the API. 
  • On the above code, you have to change the $token value to your Token and $site value to your site address.
  • Now open the index.php via your browser and start to send sms.
  • You are done.
You can also integrate the code with your web application. If you have having any trouble with the integration method. You can use forum.how.in to ask it and get your problem solved.

Suggested Article for PHP Developers:

I hope you well enjoyed this article. If you have any doubts related to this article. Comment it on the below comment box or join or forum via forum.howi.in.Thanks

0 comments:

Post a Comment

Wapmaster or Webmaster can Comment Us with the following Comment Box . Don't add Links to your site for Spamming our Blog .. Once you add Comment with Link . It will be deleted immediatly by our Admins .

 
Top