API

Getting started

XML Introduction

This document explains about how to use our SMS API. In order to send an SMS you need to use an HTTP post request by sending an XML stream. The response will also be sent in an XML Format.

All requests must be sent to https://app.smsleads.co.il/api

All responses will be according to the command request, but all look something like this:

				
					<?xml version="1.0" encoding="UTF-8"?>
<sms>
<status>0</status>
<message>SMS will be sent</message>
<shipment_id>xxxxxxx<shipment_id>
</sms>
				
			

The status field differs according to the result. when status is zero the request is valid and for any error the status number is the error number.The message also differs when the status is not zero, to explain the reason. The root element "sms" will change according to the command sent.

Get API Token

Before start using SMS LEADS API, you need your account Username and Password as you got to your mailbox while register to the service.

You can reset your accounts Password by forgot password button on login screen.

In order to use the SMS LEADS API services, generate API TOKEN is needed.

After gathering all the information – it's time to get a token.

In order to generate the API TOKEN you need to go to this URL: https://www.smsleads.co.il/getApiToken/

Then, fill out the form and SUBMIT. You will get the API TOKEN and Expiration Date.

  • After receiving the token – the token should be added to the header as “Bearer authentication” when the key is "Authorization" in every single method used.
  • The Token valid for 24 month, after this period you should generate a new one.
  • When generating a new TOKEN the old one still valid for next 7 days to allow you make the change in your system.
  • We will notice by email and SMS while period is about to end.

1. Send

1.1 Send SMS

In order to send an SMS message you must send an XML similar to the following example:

				
					<?xml version="1.0" encoding="UTF-8"?>
<sms>
<user>
<username>JohnDoe</username>
</user>
<source>DemoAPI</source>
<destinations>
<cl_id>21518</cl_id>
<cl_id>21500</cl_id>
<phone id="external id1">5xxxxxxxx</phone>
<phone id="external id2">5xxxxxxxx</phone>
<phone>5xxxxxxxx</phone>
<phone id="">5xxxxxxxx</phone> </destinations>
<tag>#</tag>
<message>This is a sample message</message>
<add_dynamic>0</add_dynamic>
<timing>30/03/21 10:10</timing>
<add_unsubscribe>0</add_unsubscribe>
<response>0</response>
</sms>
				
			

Fields:

  • sms – Required element. Contains all other elements.
  • user – Required element. Contains all user elements.
  • username – Required element. The username of the account by which you are recognized in the system.
  • source – Required element. The phone number from which you wish to send the
    SMS message. Must be maximum 11 characters and contains only numeric value (no + sign) and English letters
  • destinations – Required element. Contains all phone destinations you wish to send the SMS to. May contain multiple phone fields.
  • phone – Required element. phone number to which the SMS, must be formatted:
    5xxxxxxx or 05xxxxxxx
  • id – Optional attribute. An attribute of the phone element. If you’re interested in checking for DLR’s enter your ID for the SMS to query it later. Leave blank or don’t add it if you’re not interested.
  • Tag- Optional element . basically for GOOGLE's automatic SMS verification users ,allows you to add tag to the beginning of the message ,for example: #Hello world result=> "<#>Hello world"
  • Add_dynamic- Optional element. If you wish that the SMS will send with the Dynamic Field of the contact list, set 1, any other value would be considered as no. This will check that there are no singles tags in the XML an no more than 1 tag, • To use dynamic field, you need to use the following template: [DYNAMIC_FIELD1] for the first dynamic field and so on. For example:
    Hello [DYNAMIC_FIELD1] [DYNAMIC_FIELD2]
  • message – Required element. Contains the message to be sent to the destinations.
  • timing – Optional element. the date in which the sms to be sent. If absent then will send immediately.
  • response – Optional element. If you wish that the SMS will have response functionality set 1, any other value would be consider as no. This will have a random "source" number attached to the SMS and the value you wrote will be ignored. • Add_unsubscribe – Optional element. If you want to add SMS option for removal. Remove by link set 3, Remove by return SMS set 2, any other value would be considering as no.
  • cl_id – Optional element. If you wish send a message to a contact lists. You should enter the ID of the contact list.

In which the response will be something like:

				
					<?xml version="1.0" encoding="UTF-8"?>
<sms>
<status>0</status>
<message>SMS will be sent</message>
<shipment_id>xxxxxxx<shipment_id>
</sms>
				
			

1.2 Send bulk SMS

You also have the option to send bulk SMS, which means you can send multiple individual SMS messages, in which case the XML will be something like:

				
					<?xml version="1.0" encoding="UTF-8"?>
<bulk>
<user>
<username>JohnDoe</username>
</user>
<messages>
<sms>
<source>DemoAPI</source>
<destinations>
<phone id="external id1">5xxxxxxxx</phone>
<phone id="external id2">5xxxxxxxx</phone>
<phone>5xxxxxxxx</phone>
<phone id="">5xxxxxxxx</phone>
</destinations>
<message>This is a sample message</message>
</sms>
<sms>
<source>DemoAPI</source>
<destinations>
<phone id="">5xxxxxxxx</phone>
</destinations>
<message>This is a different message sent</message>
</sms>
</messages>
<timing>10/10/17 10:10</timing>
<response>0</response>
</bulk>
				
			

In which the response will look something like:

				
					<?xml version="1.0" encoding="UTF-8"?>
<sms>
<add_unsubscribe>0</add_unsubscribe>
<status>0</status>
<message>SMS bulk will be sent</message>
<shipment_id>xxxxxxx<shipment_id>
</sms>
				
			
  • response – Optional element. If you wish that all the SMS messages will have response functionality set 1, any other value would be consider as no. This will have a random "source" number attached to every SMS (same number to all of them) and the value you wrote will be ignored.
  • add_unsubscribe – Optional element. If you want to add SMS option for removal. Remove by link set 3, Remove by return SMS set 2, any other value would be consider as no.

2. More actions

2.1 Get balance

If you wish to check your remaining balance send an XML similar to the following example:

				
					<?xml version="1.0" encoding="UTF-8"?>
<balance>
<user>
<username>JohnDoe</username>
</user>
</balance>
				
			

Fields:

  • balance- Required element. Contains all other elements.
  • user – Required element. Contains all user elements.
  • username – Required element. The username of the account by which you are recognized in the system.

In which the response will be something like:

				
					<?xml version="1.0" encoding="UTF-8"?>
<balance>
<status>0</status>
<message>Your balance is:42</message>
<balance>42</balance>
</balance>
				
			

2.2 Get delivery reports (DLR)

2.2.1 Get delivery reports (DLR) basic

In order to get Delivery reports you must send an XML similar to the following example:

				
					<?xml version="1.0" encoding="UTF-8"?>
<dlr>
<user>
<username>JohnDoe</username>
</user>
<transactions>
<external_id>some id 1</external_id>
<external_id>some id 2</external_id>
</transactions>
<from>01/01/21 00:00</from>
<to>01/01/21 23:59</to>
</dlr>
				
			

Fields:

  • dlr- Required element. Contains all other elements.
  • user – Required element. Contains all user elements.
  • username – Required element. The username of the account by which you are recognized in the system.
  • transactions – Required element. Contains all sms destinations you wish to receive DLR’s for. May contain multiple external_id fields.
  • external_id – Required element. The id you have sent as an attribute while submitted the SMS.
  • message – Required element. Contains the message to be sent to the destinations.
  • from* – Required element. The start date to take DLR’s from. Format: dd/mm/yy hh:mm
  • to*- Required element. The end date to take DLR’s from. Format: dd/mm/yy hh:mm
  • * The date range that is allowed to pick from is a range of 1 week up to 1 year back .
  • * The max limit of DLR's in each request is 1000.

In which the response will be something like:

				
					<?xml version="1.0" encoding="UTF-8"?>
<dlr>
<status>0</status>
<message></message>
<transactions>
<transaction>
<external_id>1391438285</external_id>
<status>102</status>
<he_message>הגיע ליעד </he_message>
<en_message>Delivered</en_message>
<date>03/02/21 16:38</date>
<shipment_id>12345678<shipment_id>
</transaction>
<transaction>
<external_id>1391438286</external_id>
<status>102</status>
<he_message> הגיע ליעד </he_message>
<en_message>Delivered</en_message>
<date>03/02/21 16:38</date>
<shipment_id>12345678<shipment_id>
</transaction>
</transactions>
</dlr>
				
			

2.2.2 Get Delivery reports by date(dlrByDate)

In order to get Delivery reports without external id you must send an XML similar to the following example:

				
					<?xml version="1.0" encoding="UTF-8"?>
<dlrByDate>
<user>
<username>JohnDoe</username>
</user>
<transactions>
<external_id>null</external_id>
</transactions>
<from>01/01/21 00:00</from>
<to>01/01/21 23:59</to>
</dlrByDate>
				
			

Fields:

  • dlrByDate- Required element. Contains all other elements.
  • user – Required element. Contains all user elements.
  • username – Required element. The username of the account by which you are recognized in the system.
  • transactions – Required element. Contains all sms destinations you wish to receive DLR’s for. May contain multiple external_id fields.
  • external_id – Required element. Can contain a value of null.
  • message – Required element. Contains the message to be sent to the destinations.
  • from* – Required element. The start date to take DLR’s from. Format: dd/mm/yy hh:mm
  • to*- Required element. The end date to take DLR’s from. Format: dd/mm/yy hh:mm
  • The date range that is allowed to pick from is a range of 1 week up to 1 year back

2.3 Get Incoming SMS

In order to get Incoming reports you must send an XML similar to the following example:

				
					<?xml version="1.0" encoding="UTF-8"?>
<incoming>
<user>
<username>JohnDoe</username>
</user>
<from>01/01/15 00:00</from>
<to>01/01/15 23:59</to>
</incoming>
				
			

Fields:

  • user – Required element. Contains all user elements.
  • username – Required element. The username of the account by which you are recognized in the system.
  • from* – Required element. The start date to take DLR’s from. Format: dd/mm/yy hh:mm
  • to*- Required element. The end date to take DLR’s from. Format: dd/mm/yy hh:mm

*The date range that is allowed to pick from is a range of 1 week up to 1 year back In which the response will be something like:

				
					<?xml version="1.0" encoding="UTF-8"?>
<incoming>
<status>0</status>
<message></message>
<transactions>
<transaction>
<source>05********</source>
<destination>05********</destination>
<message>This is a sample message</message>
<date>03/12/21 16:38</date>
</transaction>
<transaction>
<source>05********</source>
<destination>05********</destination>
<message>This is a test message</message>
<date>03/12/21 12:33</date>
</transaction>
</transactions>
</incoming>
				
			

2.4 Blacklist

2.4.1 Get blacklist

If you would like to check your blocked list, please submit XML similar to the following example:

				
					<?xml version="1.0" encoding="UTF-8"?>
<blacklist>
<user>
<username>JohnDoe</username>
</user>
<from>02/06/15 00:00</from>
<to>15/12/15 23:59</to>
</blacklist>
				
			

Fields:

  • blacklist- Required element. Contains all other elements.
  • user – Required element. Contains all user elements.
  • username – Required element. The username of the account by which you are recognized in the system.
  • from* – Required element. The start date to take DLR’s from. Format: dd/mm/yy hh:mm
  • to*- Required element. The end date to take DLR’s from. Format: dd/mm/yy hh:mm

In which the response will be something like:

				
					<?xml version="1.0" encoding="UTF-8"?>
<blacklist>
<status>0</status>
<message></message>
<transactions>
<transaction>
<phone>5********</phone>
<date>03/12/21 16:38</date>
</transaction>
<transaction>
<phone>5********</phone>
<date>03/12/21 12:33</date>
</transaction>
</transactions>
</blacklist>
				
			

2.4.2 Remove phones from blacklist

If you wish to remove phones from blacklist an XML similar to the following example:

				
					<?xml version="1.0" encoding="UTF-8"?>
<rmNumBL>
<user>
<username>xxxxxx</username>
</user>
<phones>
<phone>5********</phone>
<phone>05********</phone>
</phones>
<reason>Text here</reason>
</rmNumBL>
				
			

Fields:

  • rmNumBL – Required element. Contains all other elements.
  • user – Required element. Contains all user elements.
  • username – Required element. The username of the account by which you are recognized in the system.
  • phones- Required element. Contains all phone elements.
  • phone- Required element. Contains phone you want to remove.
  • reason- Required element. Contains an text about the reason why you want to remove.

In which the response will look something like:

Success:

				
					<?xml version="1.0" encoding="UTF-8"?>
<status>944</status>
<message>X phone numbers Successfully deleted , Y Phone numbers not exist in blacklist</message>
				
			

Fail:

				
					<?xml version="1.0" encoding="UTF-8"?>
<status>933</status> <message>Phones or reason not valid</message>
				
			

2.5 Subscribers

2.5.1 Add subscriber

If you wish to add subscriber an XML similar to the following example:

				
					<?xml version="1.0" encoding="UTF-8"?>
<addSub>
<user>
<username> xxxxxx </username>
</user>
<userDetails>
<name>israel israeli</name>
<username> israelisraeli </username>
<password> israelisraeli </password>
<source>05xxxxxxxx</source>
<amount>70000</amount>
</userDetails>
</addSub>
				
			

Fields:

  • addSub – Required element. Contains all other elements.
  • user – Required element. Contains all user elements.
  • username – Required element. The username of the account by which you are recognized in the system.
  • userDetails- Required element. Contains the Details of the user that you want to start.
  • Name – Required element. Contains the name you want to give the user
  • Username- Required element. Contains the username you want to give the user.
  • Password- Required element. Contains the password you want to give the user.
  • source- Required element. Contains the source you want to give the user. Default.
  • amount – Required element. Contains the amount of credits you want to give the user. Contain only digits

In which the response will look something like:

				
					<?xml version="1.0" encoding="UTF-8"?>
<addSub>
<status>0</status>
<message>The user was created successfully</message>
</addSub>
				
			

2.5.2 Update subscribers wallets

If you wish to update the wallet of subscribers an XML similar to the following example:

				
					<?xml version="1.0" encoding="UTF-8"?>
<updateAmountSub>
<user>
<username> xxxxxx </username>
</user>
<userDetails>
<username>username1</username>
<password>password1</password>
<amount>70000</amount>
</userDetails>
</updateAmountSub>
				
			

Fields:

  • updateAmountSub- Required element. Contains all other elements.
  • user – Required element. Contains all user elements.
  • username – Required element. The username of the account by which you are recognized in the system.
  • userDetails- Required element. Contains the Details of the user that you want to update.
  • Username- Required element. Contains the username you want to update subscriber.
  • Password- Required element. Contains the password you want to update subscriber.
  • amount – Required element. Contains the amount of credits you want to give the user. Contain only digits.

In which the response will look something like:

				
					<?xml version="1.0" encoding="UTF-8"?>
<updateAmountSub>
<status>0</status>
<message>Wallet successfully updated</message>
</updateAmountSub>
				
			

2.5.3 Get the balance of all subscribers

If you wish to get the balance of all subscribers an XML similar to the following example:

				
					<?xml version="1.0" encoding="UTF-8"?>
<getBlanceSubs>
<user>
<username> xxxxxx </username>
</user>
</getBlanceSubs>
				
			

Fields:

  • getBlanceSubs – Required element. Contains all other elements.
  • user – Required element. Contains all user elements.
  • username – Required element. The username of the account by which you are recognized in the system.

In which the response will look something like:

				
					<?xml version="1.0" encoding="UTF-8"?>
<getBlanceSubs>
<status>0</status>
<message></message>
<balances> <balance>
<amount>80</amount>
<sms_user_id>xxx</sms_user_id>
<name>name1</name>
</balance> <balance>
<amount>50</amount>
<sms_user_id>xxx</sms_user_id>
<name> name2</name>
</balance> </balances>
</getBlanceSubs>
				
			

2.6 Contact lists

2.6.1 Create contact list

If you wish to create contact list an XML similar to the following example:
				
					<?xml version="1.0" encoding="UTF-8"?>
<newCL>
<user>
<username> xxxxxx </username>
</user>
<cl>
<name>name1</name>
<destinations>
<destination>
<phone>05xxxxxxxx</phone>
<df1>Israel</df1>
<df2>Israeli</df2>
<df3>Haifa</df3>
</destination>
<destination>
5xxxxxxxx</phone>
</destination>
</destinations>
</cl>
<cl>
<name>name2</name>
<destinations>
<destination>
<phone>05xxxxxxxx</phone>
</destination>
<destination>
<phone>5xxxxxxxx</phone>
</destination>
</destinations>
</cl>
</newCL>
				
			

Fields:

  • newCL – Required element. Contains all other elements.
  • user – Required element. Contains all user elements.
  • username – Required element. The username of the account by which you are recognized in the system.
  • cl- Required element. Contains the Details of the contact list that you want to start.
  • Destinations- Required element. Contains all the numbers have been added to a contact list.
  • Destination- Required element. contains the details for any phone number.
  • Phone – Required element. must be formatted: 5xxxxxxx or 05xxxxxxx.
  • df1/ df2/ df3/ df4/ df5/ df6- Optional element. contains a dynamic field for all listed telephone number.

In which the response will look something like:

				
					<?xml version="1.0" encoding="UTF-8"?>
<newCL>
<status>0</status>
<message>conact list successfully created</message>
<errors>
<error>The phone is too long or too short or contain characters and therefore not added</error>
</errors>
<identifiers>
<identifier>17419</identifier>
</identifiers>
</newCL>
				
			

Fields:

  • error- shows the possible errors in XML.
  • Identifier-returns the ID of the contact lists created.

2.6.2 Remove contact list

If you wish to create contact lists an XML similar to the following example:

				
					<?xml version="1.0" encoding="UTF-8"?>
<removeCL>
<user>
<username>xxxxxx</username>
</user>
<cl>
<id>21518</id>
<id>21500</id>
</cl>
</removeCL>
				
			

Fields:

  • removeCL – Required element. Contains all other elements.
  • user – Required element. Contains all user elements.
  • username – Required element. The username of the account by which you are recognized in the system.
  • cl- Required element. Contains identifiers you want to remove.
  • Id- Required element. Contains an id of contact list you want to remove.

In which the response will look something like:

				
					<?xml version="1.0" encoding="UTF-8"?>
<removeCL>
<status>0</status>
<message>contact list successfully removed</message>
<errors>
<error>contact list id: 21500 does not exist and therefore not removed</error>
</errors>
</removeCL>
				
			

Fields:

  • error- shows the possible errors in XML.

2.6.3 Add a number to existing contact list

If you wish to add numbers to contact list exists an XML similar to the following example:

				
					<?xml version="1.0" encoding="UTF-8"?>
<addNumCL>
<user>
<username>xxxxxx</username>
</user>
<cl>
<id>21518</id>
<destinations>
<destination>
<phone>05xxxxxxxx</phone>
<df1>Israel</df1>
<df2>Israeli</df2>
<df3>Haifa</df3>
</destination>
<destination>
<phone>5xxxxxxxx</phone>
</destination>
</destinations>
</cl>
<cl>
<id>21500</id>
<destinations>
<destination>
<phone>05xxxxxxxx</phone>
</destination>
<destination>
<phone>5xxxxxxxx</phone>
</destination>
</destinations>
</cl>
</addNumCL>

				
			

Fields:

  • addNumCL- Required element. Contains all other elements.
  • user – Required element. Contains all user elements.
  • username – Required element. The username of the account by which you are recognized in the system.
  • cl- Required element. Contains the Details of the contact list that you want to update.
  • Id- Required element. Contains Id you want to update.
  • Destinations- Required element. Contains all the numbers have been added to a contact list.
  • Destination- Required element. contains the details for any phone number.
  • Phone – Required element. must be formatted: 5xxxxxxx or 05xxxxxxx.
  • df1/ df2/ df3/ df4/ df5/ df6- Optional element. contains a dynamic field for all listed telephone number.

2.6.3 Remove a number from an existing contact lists

If you want to remove numbers from an existing contact list, send XML similar to the following example:

				
					<?xml version="1.0" encoding="UTF-8"?>
<rmNumCL>
<user>
<username>xxxxxx</username>
</user>
<cl>
<id>21518</id>
<destinations>
<phone>05xxxxxxxx</phone>
</destinations>
</cl>
<cl>
<id>21500</id>
<destinations>
<phone>05xxxxxxxx</phone>
<phone>5xxxxxxxx</phone>
</destinations>
</cl>
</rmNumCL>

				
			

Fields:

  • rmNumCL- Required element. Contains all other elements.
  • user – Required element. Contains all user elements.
  • username – Required element. The username of the account by which you are recognized in the system.
  • cl- Required element. Contains the Details of the contact list that you want to update.
  • Id- Required element. Contains Id you want to update.
  • Destination- Required element. Contains all the numbers have been removed from the contact list.
  • Phone – Required element. must be formatted: 5xxxxxxx or 05xxxxxxx.

In which the response will look something like:

				
					<?xml version="1.0" encoding="UTF-8"?>
<rmNumCL>
<status>0</status>
<message>Successfully deleted phone numbers</message>
<errors>
<error>contact list id: 21500 does not exist and therefore not removed</error>
</errors>
</rmNumCL>
				
			

Fields:

  • error- shows the possible errors in XML.

2.6.4 Get all contact lists

If you wish to get the contact lists (include empty contact lists), an XML similar to the following example:

				
					<?xml version="1.0" encoding="UTF-8"?>
<getCL>
<user>
<username> xxxxxx </username>
</user>
</getCL>
				
			

Fields:

  • getCL – Required element. Contains all other elements.
  • user – Required element. Contains all user elements.
  • username – Required element. The username of the account by which you are recognized in the system.

In which the response will look something like:

				
					<?xml version="1.0" encoding="UTF-8"?>
<getCL>
<status>0</status>
<message></message>
<contact_lists>
<contact_list>
<cl_id>21518</cl_id>
<phone>5xxxxxxxx</phone>
<name>name1</name>
</contact_list>
<contact_list>
<cl_id>21518</cl_id>
<phone>5xxxxxxxx</phone>
<name>name1</name>
</contact_list>
<contact_list>
<cl_id>21500</cl_id>
<phone>05xxxxxxxx</phone>
<name>name2</name>
</contact_list>
</contact_lists>
</getCL>
				
			

2.6.5 Get contact lists by ID

If you wish to get contact lists by ID an XML similar to the following example:

				
					<?xml version="1.0" encoding="UTF-8"?>
<getCLbyID>
<user>
<username> xxxxxx </username>
</user>
<cl>
<id>xxxxx</id>
</cl>
</getCLbyID>
				
			

Fields:

  • getCLbyID – Required element. Contains all other elements.
  • user – Required element. Contains all user elements.
  • username – Required element. The username of the account by which you are recognized in the system.
  • cl – Required element. Contains contact list elements
  • Id- Required element. Contains an id of contact list you want to get.

In which the response will look something like:

				
					<?xml version="1.0" encoding="UTF-8"?>
<getCLbyID>
<status>0</status>
<message></message>
<contact_lists>
<contact_list>
<phone>5xxxxxxxx</phone>
<name>name1</name>
</contact_list>
<contact_list>
<phone>5xxxxxxxx</phone>
<name>name1</name>
</contact_list>
<contact_list>
<phone>05xxxxxxxx</phone>
<name>name2</name>
</contact_list>
</contact_lists>
</getCLbyID>
				
			

2.7 Cancel campaign

If you want to cancel your campaign send an XML similar to the following example:

				
					<?xml version="1.0" encoding="UTF-8"?>
<cancel>
<user>
<username>JohnDoe</username>
</user>
<campaign_id>campaign1</campaign_id>
</cancel>
				
			

Fields:

  • cancel- Required element. Contains all other elements.
  • user – Required element. Contains all user elements.
  • username – Required element. The username of the account by which you are recognized in the system.
  • campaign_id- Required element. The number of the your campaign

In which the response will be something like:

				
					<?xml version="1.0" encoding="UTF-8"?>
<cancel>
<status>0</status>
<message>Campaign successfuly cancel</message>
</cancel>
				
			

2.8 Verify phone

In order to verify phone to be an sms source number you must send an XML similar to the following example:

				
					<?xml version="1.0" encoding="UTF-8"?>
<verify_phone>
<user>
<username>JohnDoe</username>
</user>
<phone>5xxxxxxxx</phone>
<phone>3xxxxxxx</phone>
</verify_phone>
				
			

Fields:

  • verify_phone – Required element. Contains all other elements.
  • user – Required element. Contains all user elements.
  • username – Required element. The username of the account by which you are recognized in the system.
  • phone – Required element (one or more). The phone you want to use as a sms source number,
  • The phone must be a legal mobile or landline number.

In which the response will be something like:

				
					<?xml version="1.0" encoding="utf-8"?>
<verify_phone>
<status>0</status>
<verify_message>
verification link will be send to 5xxxxxxxx
in order to complete the verification of 3xxxxxxx call to 05xxxxxxxx
</verify_message>
</verify_phone>
				
			

2.9 PHP examples

2.9.1 PHP Example #1

				
					<?php
$url = "https://app.smsleads.co.il/api";
$key = 'put_your_API_TOKEN_here';
$xml ='
<?xml version="1.0" encoding="UTF-8"?>
<sms>
<user>
<username>JohnDoe</username>
</user>
<source>DemoAPI</source>
<destinations>
<phone id="someid1">5xxxxxxx</phone>
<phone id="someid2">5xxxxxxx</phone>
</destinations>
<message>This is an example</message>
</sms>';
$CR = curl_init();
curl_setopt($CR, CURLOPT_URL, $url);
curl_setopt($CR, CURLOPT_POST, 1);
curl_setopt($CR, CURLOPT_FAILONERROR, true);
curl_setopt($CR, CURLOPT_POSTFIELDS, $xml);
curl_setopt($CR, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($CR, CURLOPT_HTTPHEADER, array( 'charset=utf-8', 'Content-Type: application/json', 'Authorization: Bearer ' . $key ) );
$result = curl_exec($CR); $error = curl_error($CR);
if (!empty($error)) die("Error: " . $error);
else $response = new SimpleXMLElement($result);
?>

				
			

2.9.2 PHP Example #2

				
					<?php
$curl = curl_init();
$key = 'put_your_API_TOKEN_here';
curl_setopt_array($curl, array(
CURLOPT_URL => "https://app.smsleads.co.il/api",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "<?xml version='1.0' encoding='UTF-8'?>
\r\n <sms>\r\n <user>\r\n <username>my_username</username>
\r\n </user>\r\n <source>sender</source>
\r\n <destinations>\r\n <phone id='someid1'>0500123456</phone>
\r\n </destinations>\r\n <message>test</message>\r\n </sms>",
CURLOPT_HTTPHEADER => array(
"Cache-Control: no-cache",
"Content-Type: application/xml", "Authorization: Bearer ". $key
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
				
			

2.10 C# Example

				
					using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Text; // for class Encoding
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            String url = "https://app.smsleads.co.il/api";
            String xml = "<?xml version='1.0' encoding='UTF-8'?><sms><user><username>xxx</username></user><source>DemoAPI</source><destinations><phone>05xxxxxxx1</phone><phone>05xxxxxxx2</phone></destinations><message>test</message></sms>";
            WebRequest webRequest = WebRequest.Create(url);
            webRequest.Method = "POST";
            byte[] bytes = Encoding.UTF8.GetBytes(xml);
            webRequest.ContentType = "application/xml";
            webRequest.ContentLength = (long)bytes.Length;
            Stream requestStream = webRequest.GetRequestStream();
            requestStream.Write(bytes, 0, bytes.Length);
            requestStream.Close();
            WebResponse response = webRequest.GetResponse();
            Stream responseStream = response.GetResponseStream();
            StreamReader streamReader = new StreamReader(responseStream);
            string result = streamReader.ReadToEnd();
            streamReader.Close(); responseStream.Close(); response.Close();
            Console.WriteLine(result);
        }
    }
}

				
			

3. Error codes

This is table that explains each response code and it’s message for API calls:

Status 

Message 

0 

* 

1 

There was a problem parsing your XML 

2 

** 

3 

Username or password is incorrect and API token is invalid 

4 

Not enough credit, Purchase Now. 

5 

No permission to send SMS at this time 

6 

Process failure 

7 

You can not send in this format,you need send group in 'bulk', For more – call to Customer Service. 

8 

All numbers are on a blocked list 

9 

destination/source/message length is too large or too small 

10 

Username or password is incorrect and Expired API token 

11 

API token is valid but doesn't match username or if you have newer token you should use it instead 

502 

action type not valid 

503 

username not exist in your account 

504 

current token not found 

510 

invalid verify_phone request: no phones to verify 

511 

you have not permission for this function 

933 

Phone or reason not valid 

944 

Some of numbers not in blacklist 

955 

Campaign already cancel 

966 

Campaign already sent 

977 

Campaign does not belong to customer or Not exist 

986 

Add unsubscribe error- invalid value 

988 

Contact list are entered not exist 

989 

The message is too long or too short 

990 

Amount must be small amount of your credits 

991 

The amount must contain only digits 

992 

The source is too long or too short 

993 

The password is too long or too short 

994 

Username already exists 

995 

The username is too long or too short 

996 

The name is too long or too short 

997 

Not a valid command sent 

998 

There was an unknown error in the request 

999 

Contact support 

* Status code 0 means successful transaction. Will contain a positive message according to the API command sent.
Example: "SMS will be sent"
**Status code 2 means that one of the XML fields was missing. The message would say what field is missing.

© All rights reserved SMS Leadsfrom Exsile Digital Group

[credits_exsile][credits_web_development][credits_digital_marketing]