Hello Folks,
Recently i have Done with My SMS API Work. I Have Created API for 20 Gateways.
Today I am going to explain how to use my SMS API service in your own application. Please find the example source codes given below.
1. C# Example. Can be used directly in any .NET Application.
2. VB.NET example
3. PHP example.
4. Java Example
5. Ruby example
Required Params : uid, pwd, phone, msg.
uid : your userid for the required sms provider
pwd : your password for the required sms provider
provider : way2sms(default), fullonsms, smsindia, whozzat, smsinside, site2sms. if you do not specify any provider, way2sms will be used by default.
phone : phone number whom you want to send sms. seperate multiple phone numbers with a comma (,)
msg : your sms message, unlimited chars. will be sent as multiple msgs if crosses the message length for any provider
Optional Parameters
ck : 1. Send this if you require a user friendly msg from the server. for example, if codes=1 is not provided the server will return the result as an integer.
1 – SMS sent
-1 – Invalid Username & Password
2 – Error Sending Message
-2 – Invalid Numbers
0 – All Data Required
Currently, the following service providers are supported for SMS sending.
Way2SMS=>140 Characters
Site2SMS=>260 Characters
160By2=>140 Characters
FullonSMS=>140 Characters
Fast2SMS=>130 Characters
SMSFi=>125 Characters
SMSAbc=>148 Characters
FreeSMS8=>136 Characters
SMS440=>440 Characters
Ultoo=>140 Characters
100Nests=>160 Characters
YouMint=>160 Characters
SMSiNeed=>130 Characters
IndyaRocks=>130 Characters
TimesinSMS=>140 Characters
SMSSpark=>140 Characters
Net2Mobiles=>140 Characters
SMSZe=>300 Characters
SMSFunk=>270 Characters
Total160=>140 Characters
Try My SMS Api at http://sms.Cikly.iN
You Can Also Download its Google Chrome Extension From Here : Free SMS Sender - Google Chrome extension - Cikly
Happy SMSing!!!
Recently i have Done with My SMS API Work. I Have Created API for 20 Gateways.
Today I am going to explain how to use my SMS API service in your own application. Please find the example source codes given below.
1. C# Example. Can be used directly in any .NET Application.
Code:
public void send(string uid, string password, string message, string no) { HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://smsapi.cikly.in/index.php?uid=" + uid + "&pwd=" + password + "&msg=" + message + "&phone=" + no + "&provider=way2sms"); HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse(); System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream()); string responseString = respStreamReader.ReadToEnd(); respStreamReader.Close(); myResp.Close(); }
Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim sURL As String Dim objReader As StreamReader sURL = "http://smsapi.cikly.in/index.php?uid=9898123456&pwd=way2smspwd&msg=Hi&phone=9898123456&provider=way2sms" Dim sResponse As WebRequest sResponse = WebRequest.Create(sURL) Try Dim objStream As Stream objStream = sResponse.GetResponse.GetResponseStream() objReader = New StreamReader(objStream) Response.Write(objReader.ReadToEnd()) objReader.Close() Catch ex As Exception ex.Message End Try End Sub
Code:
$uid = 'USERNAME'; $pwd = 'PASSWORD'; $phone = 'SEND MSG TO PHONE NO'; $msg = 'MESSAGE TEXT'; $provider = 'Ultoo, SMSSpark, Youmint or any other provider supported by Cikly.iN'; $content = 'uid='.rawurlencode($uid). '&pwd='.rawurlencode($pwd). '&phone='.rawurlencode($phone). '&msg='.rawurlencode($msg). //'&ck=1'. // Use if you need a user freindly response message. '&provider='.rawurlencode($provider); $sms_response = file_get_contents('http://smsapi.cikly.in/index.php?' . $content); echo $sms_response;
Code:
import java.net.*; import java.io.*; public class SmsSender { //Replace your way2sms username and password below static final String _userName = "your way2sms username"; static final String _password = "your way2sms password"; static final String _url = "http://smsapi.cikly.in/index.php"; static final String charset = "UTF-8"; //to build the query string that will send a message private static String buildRequestString(String targetPhoneNo, String message) throws UnsupportedEncodingException { String [] params = new String [5]; params[0] = _userName; params[1] = _password; params[2] = message; params[3] = targetPhoneNo; params[4] = "way2sms"; String query = String.format("uid=%s&pwd=%s&msg=%s&phone=%s&provider=%s", URLEncoder.encode(params[0],charset), URLEncoder.encode(params[1],charset), URLEncoder.encode(params[2],charset), URLEncoder.encode(params[3],charset), URLEncoder.encode(params[4],charset) ); return query; } public static void sendMessage(String reciever, String message) throws Exception { //To establish the connection and perform the post request URLConnection connection = new URL(_url + "?" + buildRequestString(reciever,message)).openConnection(); connection.setRequestProperty("Accept-Charset", charset); //This automatically fires the request and we can use it to determine the response status InputStream response = connection.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(response)); System.out.println(br.readLine()); } public static void main(String [] args) throws Exception { String testPhoneNo = "9876543210"; String testMessage = "Sending Messages From java is not too hard"; sendMessage(testPhoneNo,testMessage); } }
Code:
require "net/http" class SmsSender def initialize(user_phone, password, provider = "way2sms") @sender = user_phone @password = password @provider = provider end def send(recipient,message) uri = URI("http://smsapi.cikly.in/index.php") params = { uid: @sender, pwd: @password, phone: recipient, msg: message, provider: @provider } uri.query = URI.encode_www_form(params) response = Net::HTTP.get_response(uri) if response.is_a?(Net::HTTPSuccess) && response.body == "1" puts "Message Sent" else puts "Something Went Wrong. Error Code = #{response.body}" end end end #sample usage way2sms = SmsSender.new("USERID","PASSWORD") way2sms.send("PHONE","MSG")
uid : your userid for the required sms provider
pwd : your password for the required sms provider
provider : way2sms(default), fullonsms, smsindia, whozzat, smsinside, site2sms. if you do not specify any provider, way2sms will be used by default.
phone : phone number whom you want to send sms. seperate multiple phone numbers with a comma (,)
msg : your sms message, unlimited chars. will be sent as multiple msgs if crosses the message length for any provider
Optional Parameters
ck : 1. Send this if you require a user friendly msg from the server. for example, if codes=1 is not provided the server will return the result as an integer.
1 – SMS sent
-1 – Invalid Username & Password
2 – Error Sending Message
-2 – Invalid Numbers
0 – All Data Required
Currently, the following service providers are supported for SMS sending.
Way2SMS=>140 Characters
Site2SMS=>260 Characters
160By2=>140 Characters
FullonSMS=>140 Characters
Fast2SMS=>130 Characters
SMSFi=>125 Characters
SMSAbc=>148 Characters
FreeSMS8=>136 Characters
SMS440=>440 Characters
Ultoo=>140 Characters
100Nests=>160 Characters
YouMint=>160 Characters
SMSiNeed=>130 Characters
IndyaRocks=>130 Characters
TimesinSMS=>140 Characters
SMSSpark=>140 Characters
Net2Mobiles=>140 Characters
SMSZe=>300 Characters
SMSFunk=>270 Characters
Total160=>140 Characters
Try My SMS Api at http://sms.Cikly.iN
You Can Also Download its Google Chrome Extension From Here : Free SMS Sender - Google Chrome extension - Cikly
Happy SMSing!!!
Comment