Developers Guide
PHP
<?php
/* Send an SMS using this aplication. You can run this file 3 different ways:
*
* Download a local server like WAMP, MAMP or XAMPP. Point the web root
* directory to the folder containing this file, and load
* localhost:8888/client.php in a web browser.
*/
// include the Sms class
include_once 'Sms.php';
class MainSms
{
public function call()
{
//instantiate a new Sms Rest Client with argument api,senderID,base_URL
$sms = new Sms('A40e3879f034xxxxxxxxxxxx', 'SENDER',
'http://yourserviceproviderdomainurl.com/api/v4/?');
// Sending an sms instantly
// Pass api key and senderid of your account
$dlr_url = 'https://yourdomain.net/dlr/trigger.php?sent={sent}&delivered={delivered}&msgid=
{msgid}&sid={sid}&status={status}&reference={reference}&custom1={custom1}&custom2={custom2}';
$obj = $sms->sendSms('78xxxxxxxx', 'test message', [
'dlr_url' => $dlr_url,
//Delivery URL for passing replaceable parameters` values after sending SMS
'time' => '2017-06-11 11:17:55 AM',
// Schedule SMS; Params are To, message, dlrurl, format, time, method
'unicode' => '1',
//Sending Unicode SMS; Params are To, message, dlrurl, format, method
'flash' => '1',
//SMS will appear on the recipient notification screen; further will be saved to Inbox
'format' => 'json',
'port' => '8213', ]
//Send a normal or unicode SMS to the given port number
);
/*$xml="<?xml version='1.0' encoding='UTF-8'?><xmlapi>
<sender>RRRRRR</sender>
<message>xml test</message>
<unicode>1</unicode>
<flash>1</flash>
<campaign>xml test</campaign>
<dlrURL><![CDATA[http://example.php?sent={sent}&delivered={delivered}&msgid={msgid}&sid={sid}&status={status}&reference={reference}&custom1={custom1}&custom2={custom2}&credits={credits}]]></dlrURL>
<sms><to>782xxxxxxx</to><custom>22</custom><custom1>99</custom1><custom2>988</custom2></sms>
<sms><to>9986xxxxxx</to><custom>229</custom><custom1>995</custom1><custom2>98</custom2></sms>
</xmlapi>";
$obj = $sms->sendSmsUsingXmlApi($xml,['formate'=>'json']);*/
/*$json = "{\"message\": \"test json\",
\"sms\": [{
\"to\": \"78xxxxxxxx\",
\"msgid\": \"1\",\"message\": \"test json\",
\"custom1\": \"11\",
\"custom2\": \"22\",
\"sender\": \"RRRRRR\"
},
{
\"to\": \"99xxxxxxxx\",
\"msgid\": \"2\",
\"custom1\": \"1\",
\"custom2\": \"2\" }],
\"unicode\": 1,
\"flash\": 1,
\"dlrurl\": \"http://yourdomainname.net/dlr/trigger.php?referenceid={reference}%26status={status}%26delivered={delivered}%26messageid={messageid}%26customid1={custom1}%26customid2={custom2}%26senttime={senttime}%26reference={reference}%26message={message}\"
}";
$obj = $sms->sendSmsUsingJsonApi($json,['formate'=>'json']);*/
//$obj = $sms->smsStatusPush("782xxxxxxx","hi......",$dlr_url);
// To push status of any message
$obj = $sms->smsToOptinGroup("message","groupname",['time' => '2017-06-11 11:17:55 AM',
'unicode' => '1',
'flash' => '1',
'formate'=>'json']);
//Send message to any existing Optin group
$obj = $sms->addContactsToGroup("RRRRRR","782xxxxxxx",['fullname'=>'abc','formate'=>'json']);
// To add contact(s) to any existing group
$obj = $sms->sendMessageToGroup("message","groupname","6416300217");
//Send message to any existing group
$obj = $sms->editSchedule("2017-09-23 11:17:55 AM","6416300217",['formate'=>'json']);
// Modify any scheduled message
$obj = $sms->deleteScheduledSms("6416300217",['formate'=>'json']);
// Delete any scheduled message
$obj = $sms->creditAvailabilityCheck(['formate'=>'json']);
// check available credits in your account
$obj = $sms->createtxtly("https://in.yahoo.com",['format' => 'json']);
// Create any txtly URL
$obj = $sms->deletetxtly("205",['format' => 'json']);
// Delete any existing Txtly URL
$obj = $sms->txtlyReportExtract(['format' => 'json']);
// To pull reports for all Txtly you have created
$obj = $sms->pullLogForIndividualtxtl("223",['format' => 'json']);
// To pull logs for any Txtly; simply put Txtky ID
$obj = $sms->smsStatusPull('msg-Id');
// To check Delivery status of the sent message
//Put Message ID of the particular message for which you want to check delivery status
$obj = $sms->SILookup('78xxxxxxxxx', ['format' => 'json']);
//For checking Home Location Register information for any number(s)
echo '<pre>';
print_r($obj);
}
}
$main = new MainSms();
$main->call();
?>
Note: Download the source code from here
- Extract the downloaded file
- Copy the above sample code and save it with extension .php (say trigger.php) in extracted folder
- Now call trigger.php
JAVA
public class call
{
public static void main(String[] args) throws Exception
{
SendSms smsObj = new SendSms();
/*
* Setting up parameters
* Method can be sms or sms.status
* Api_key which you can get from developer section
* Sender_Id from which you want to execute the SMS campaign
*/
smsObj.setParams("http://trans.kapsystem.com", "sms", "Api_key", "Sender_Id");
/*
* Sending Normal SMS
* Mobile_Number: valid mobile number with country prefix
* Text_Message: SMS content
* Dlr_Url: Delivery url ex : http://www.yourdomainname.domain/yourdlrpage&custom=XX
*/
smsObj.sendSms("Mobile_Number;", "Text_Message", "Dlr_Url");
//smsObj.scheduleSms("Mobile_Number", "Text_Message", "Dlr_Url", "YYYY-MM-DD HH:MM:SS");
//smsObj.sendUnicodeSms("Mobile_Number", "Text_Message", "Dlr_Url");
//smsObj.scheduleUnicodeSms("Mobile_Number", "Text_Message", "Dlr_Url", "YYYY-MM-DD HH:MM:SS");
//smsObj.messageDeliveryStatus("Msg_Id");
//smsObj.groupDeliveryStatus("Group_Id");
//smsObj.setSenderId("Sender_Id");
//smsObj.setApiKey("Api_Key");
//smsObj.setApiUrl("URL");
}
}
Note: Download the source code from here
- Extract the downloaded file
- Copy the above sample code and save it with extension .java (say call.java) in extracted folder
- Now call call.java
ASP.NET
Imports System
Imports System.Net
Imports System.IO
Imports System.Web
Dim sURL As String
sURL = "http://trans.kapsystem.com/v4/?method=sms&api_key=A62XXXXXXXXXXXXXXX&to=95XXXXXXX&sender=SIXXXX&message=test" + HttpUtility.UrlEncode("This is test message")
Dim wrGETURL As WebRequest
wrGETURL = WebRequest.Create(sURL)
Dim objStream As Stream
objStream = wrGETURL.GetResponse.GetResponseStream()
Dim objReader As New StreamReader(objStream)
Dim sLine As String = ""
Dim i As Integer = 0
sLine = objReader.ReadLine
If Not sLine Is Nothing Then
MsgBox(sLine)
End If