Saturday, November 21, 2015

SMS Gateway API Integration in PHP with Curl

API  stands for application program interface. As a programmer or developer we have to use several web service through API. API give  us privilege to integrate specific web service to use from the provider. There is a lot of good article on API you can found in  internet. Just google it, you will a lot of references. Today i am going to share basic of SMS gateway integration in your application like, school management software, Client management system etc. I will use PHP as programming with a very powerful library which is called curl.
We are using HTTP API of the  SMS gateway provider. To send the HTTP request we use curl here.

Here the code block, that is use



<?php if(isset($_POST['operation'])){ $number=$_POST['number']; $msg=$_POST['msg']; //sms gateway api link $url="http://121.241.242.114:8080/sendsms?username=syit-test&password=12345&type=0&dlr=1&destination=$number&source=DEMO&message=$msg"; $c = curl_init(); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_setopt($c, CURLOPT_URL, $url); $contents = curl_exec($c); curl_close($c); echo 'SMS Sent, thank you'; }



In above code, you see i have got two variable $number and $msg from a form by POST method and put it in the SMS gateway API link. Username and password is the login credentials is the gateway portal and the source=DEMO is the default alphabetic name created in my account. It can be any name.

Here is video i have uploaded in my youtube channel, though it is created in Bengali but think it can be help even if you are not native.


Hope it helps you. Happy coding....

8 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. sir i have seen your video of sms api integration, will you please help me how to send sms to many by just fetching number from database.

    thanks
    shashibhushan0911@gmail.com

    ReplyDelete
  4. This is very interesting post. SMS marketing has become really beneficial in modern scenario because it is the easiest method to convey your messages to the potential audience. Even I have been using car sales text messages service and really happy with the results.

    ReplyDelete
  5. If we take today's lifestyle everyone needs fast action and results. So in the field of advertising and increase your visibility in the market then Bulk SMS API is the best option for the market.

    ReplyDelete