PHP Script to Retrieve Long code Incoming SMS Data from SMS Provider
2 Way SMS Services allows you to receive information from your users using SMS Services. When a user, sends an SMS to a Short code or Long code number, you can actually retrieve that data on you website. The following PHP script will simply help you understand how you can retrieve Long code Incoming SMS data from your SMS provider.
Availing Short code / Long code Services:
You need to first of all, avail Short code / Long code Services from SMS Service Provider. Signup and get your Short code number, for example: 12345. Once you are assigned with number, now you have to decide your keyword where your user can mention the keyword and send you the required information, for example: SGCSMS as your keyword. A user can send SMS from his mobile device to your assigned Shortcode number as shown below in the image screenshot.
Shortcode Incoming SMS – Retrieve Data on your Website:
Once you are up and done with your Short code SMS settings, now you want to retrieve that data from your Incoming SMS Provider on your website.
First thing First: When you ask your SMS provider that you want to retrieve Long code Incoming SMS data, they would ask you to set up a script where they can forward the data using HTTP request. So, you need to come up with a programming script to receive data on your website. Lets take a sample code how you can retrieve the information.
Programming your PHP Script:
Save the following file as incoming_sms.php
<?php
//If you are planning to insert this data in your database, then create a database connection file and include the file name as shown below.
//ofcourse uncomment the following if you have that file
//include('db_con.php');
//We send out various information such as circle, operator, etc.,
//2 important parameters are Recepient Phone Number and Message
//So you can just grab those 2 important parameters as shown below.
//If $_GET is not working then try $_REQUEST
$incoming_sms_no = $_GET['phonecode']; //Short code or Long Code number [OPTIONAL]
$incoming_sms_keyword = $_GET['keyword']; //Short code or Long Code Keyword such as MYCOMPANY [OPTIONAL]
$recepient_mobile = $_GET['phoneno'];
$recepient_message = $_GET['content'];
$recepient_circle = $_GET['location']; //Recepient's Circle or Location [OPTIONAL]
$recepient_operator = $_GET['carrier']; //Recepient's Operator Name such as Idea, Airtel [OPTIONAL]
//Now you can print all the received data or insert it in your database.
echo $incoming_sms_no;
echo "<br />";
echo $incoming_sms_keyword;
echo "<br />";
echo $recepient_mobile;
echo "<br />";
echo $recepient_message;
echo "<br />";
echo $recepient_circle;
echo "<br />";
echo $recepient_operator;
echo "<br />";
//OR
//If you are planning to capture in the database, then store the values to your database table
You can also download the code in text file, Download Incoming SMS Script
Once you save this file, now upload to your website’s server. If you are uploading to the root server, then your URL would be
https://mysite.com/incoming_sms.php
Before giving this URL to your SMS provider, first test yourself by calling the complete URL such as
https://mysite.com/incoming_sms.php?phonecode=12345&keyword=SGCSMS&phoneno=9930447726&content=please+call+back+as+am+interested+in+your+services&location=Mumbai&carrier=Idea
Once you are satisfied with the results, then go ahead.
You have to give the above PHP script URL to your SMS Provider to forward the data. Once they start forwarding Incoming SMS Data, you will receive Incoming SMS data on your website. If the forwarding works okay then your developer can further code to store those data in your database or write to a file on your server for your easy access.
SMS Gateway Center provides Long code Incoming SMS services in India, if you are looking for Long code SMS Services, contact us with your requirement. We will be happy to assist you with best service in the industry.
If you are looking for Long code SMS Services Script, we can also develop it for your website along with SMS services for retrieving Long code SMS Data on your website with user interface, then you can rely on SMS Gateway Center.
Looking for for SMS Developers API documentation? Go straight to SMS API Documentation.
Have we missed something in this tutorial, let us know in the comments.
2 Comments
online bulk sms free
My cousin proposed I’d possibly in this way web page. He / she once was 100 % appropriate online bulk sms free. The following send actually designed this time. You can’t consider the best way a whole lot time frame I needed invested just for this facts! Appreciate it!
bulk sms send
You actually allow it to become look so easy along with your demonstration on the other hand in discovering this disorder for being essentially something I think I’d in no way have an understanding of.. bulk sms send This indicates far too complicated as well as extensive in my opinion. We’re looking ahead of time in the up coming organize, I am going to make an effort to receive the hold of this!