Monday, October 31, 2011

Create Free SMS app using PHP, JSON API, cURL and txtWeb

The current period is SMS era. Where in just 140 character made twitter dominate the social media. We are used to have everything right now as "Short and Sweet".



In India Short Messaging Service is one of the most important mode of communication today, which gave birth to lot of Start ups concentrate on SMS based solutions. txtWeb.com is one such website which provide more than 1000+ apps to choose for free of cost in India, USA & Canada.
Just type keyword for the service you are looking for and SMS it to 92433 42000 in India and 650.385.8882 in US and Canada.

The eagerness to make an SMS App drive me crazy so i felt it would help you too from this tutorial.

Step 1
Register at http://txtweb.com

txtWeb - Registration

Step 2

txtWeb - Welcome

Step 3
Verify the email inbox to activate your txtWeb.com developer account

txtWeb-activation

Step 4
There are two ways of creating SMS App here, in order to answer the dynamic input as SMS choose "Create txtApp"
txtWeb-createApp
Step 5
Enter the details of your FREE SMS application, the path is your web space where the below php script is to be uploaded via FTP.
 txtWeb-details
Step 6
Test the SMS APP before publishing. We may make use of Emulator provided by them or our mobile phone
txtWeb-test-app

Click on Edit to get the Application Key

Step 7
Get the Application key and use it in the code where every needed
Step 8
Get the API KEY from http://ipinfodb.com with the help of our previous post "finding the Real IP address details"
< ?php
/**
* GetIpDetails
* Author : S.MohanKumar smartmohi@gmail.com
* IP API from ipinfodb.com
* SMS from txtWeb.com
* Date : 1/Nov/2011 4:00AM IST
**/
echo "<html>
<head>
<meta name="txtweb-appkey" content="txtWEB.com-ApplicationKey-From-STEP-7">
</meta></head>
<body>";
$realIp='';
if(isset($_GET['txtweb-message'])) $realIp = $_GET['txtweb-message'];
if(filter_var($realIp, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
$ipDetails_json =GetIpDetails($realIp);
$obj = json_decode($ipDetails_json);
echo "IPaddress : ".$obj->{'ipAddress'}."<br />"; // IpAddress
echo "Country name : ".$obj->{'countryName'}."<br />"; // countryName
echo "State name : ".$obj->{'regionName'}."<br />"; // regionName
echo "City name : ".$obj->{'cityName'}."<br />"; // cityName
echo "Latitude : ".$obj->{'latitude'}."<br />"; // latitude
echo "Longitude : ".$obj->{'longitude'}."<br />"; // longitude
echo "Time zone : ".$obj->{'timeZone'}."<br />"; // timeZone
return;
}
else {
echo "Sorry Invalid IP address! Try again<br />@IpInfo Valid-IP";
}
function GetIpDetails($realIp){
//check if you have curl loaded
if(!function_exists("curl_init")) die("cURL extension is not installed");
// create a new cURL resource
$ch = curl_init();
//ipinfodb.com API Key
$ipinfodbApiKey='ipInfoDB.com-API-KEY';
// set URL and other appropriate options
$url="http://api.ipinfodb.com/v3/ip-city/?key=".$ipinfodbApiKey."&format=json&ip=".$realIp;
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HEADER, false);
// grab URL and pass it to the browser
$ipDetails_json=curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
return $ipDetails_json;
}
echo "</body>
";
?>
Copy this code and upload into the web server path stated in Step 5 in input field "I want to enter an AppSite URL"

Step 9
Now Test the Application with Emulator provided by txtWeb.com

txtWeb-Test-emulator

Step 10
Enter inside the emulator as
@ipinfo 59.164.102.xxx

The Output Will be like this.

SMS to 9243342000 (from India)
@IpInfo ValidIpaddress
Eg. @IPInfo 127.0.0.1

5 comments:

  1. Internet web marketing can make the world your oyster, that is, if you have a good plan, preparation and persistence in mind.
    webmarketing

    ReplyDelete
  2. The service http://www.intistele.com/ also uses a range of programming languages and API SMS integration. The perfect solution for your business.

    ReplyDelete
  3. I wondered upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.
    Digital Mobile Marketing
    SMS API
    SMS Marketing

    ReplyDelete
  4. Nice it seems to be good post... It will get readers engagement on the article since readers engagement plays an vital role in every blog.i am expecting more updated posts from your hands.
    iOS App Development Company
    Android App Development Company

    ReplyDelete
  5. I wondered upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.

    Sms marketing
    Text message marketing
    Fitness SMS

    ReplyDelete