<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Text Marketer - Email SMS, Bulk SMS Gateway, SMS Marketing Blog &#187; Technical</title>
	<atom:link href="http://www.textmarketer.co.uk/blog/category/technical/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.textmarketer.co.uk/blog</link>
	<description>SMS Gateway</description>
	<lastBuildDate>Tue, 07 Feb 2012 09:50:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>SMS API Integration – You Choose Your Level of Support</title>
		<link>http://www.textmarketer.co.uk/blog/2011/10/sms-marketing-ideas/sms-api-integration-%e2%80%93-you-choose-your-level-of-support/</link>
		<comments>http://www.textmarketer.co.uk/blog/2011/10/sms-marketing-ideas/sms-api-integration-%e2%80%93-you-choose-your-level-of-support/#comments</comments>
		<pubDate>Wed, 26 Oct 2011 07:58:00 +0000</pubDate>
		<dc:creator>Henry</dc:creator>
				<category><![CDATA[News and Case Studies]]></category>
		<category><![CDATA[SMS Marketing Ideas & Advice]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[sms api]]></category>

		<guid isPermaLink="false">http://www.textmarketer.co.uk/blog/?p=3648</guid>
		<description><![CDATA[At Text Marketer we speak to a good number of software development companies. Usually they are adding an SMS sending facility to an existing piece of software. So this might be used for sending appointment reminders, order confirmations or a huge range of other SMS notifications. Integrating a system with &#8230; <a href="http://www.textmarketer.co.uk/blog/2011/10/sms-marketing-ideas/sms-api-integration-%e2%80%93-you-choose-your-level-of-support/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div id="attachment_3655" class="wp-caption alignright" style="width: 304px"><a href="http://www.textmarketer.co.uk/wordpress/wp-content/uploads/2011/10/judy-murray-420x0.jpg"><img class="size-full wp-image-3655 " title="Judy Murray" src="http://www.textmarketer.co.uk/wordpress/wp-content/uploads/2011/10/judy-murray-420x0.jpg" alt="SMS API Integration Support" width="294" height="221" /></a><p class="wp-caption-text">SMS API Integration Support. Do you need the level of support Andy Murray receives?</p></div>
<p>At Text Marketer we speak to a good number of software development companies. Usually they are adding an SMS sending facility to an existing piece of software. So this might be used for sending appointment reminders, order confirmations or a huge range of other SMS notifications.</p>
<p>Integrating a system with Text Marketer&#8217;s<a href="http://www.textmarketer.co.uk/developers/"> SMS API</a> so that the system can generate simple outbound texts is very straightforward. Things can become slightly more complicated if a system needs to receive texts, process delivery reports or automatically respond to the incoming text. With SMS API integration, the devil, (as so often is the case), is in the detail. Different levels of SMS API complexity needs different levels of support.</p>
<p>Text Marketer SMS API customers can choose the level of support that they need. Every customer has a dedicated SMS API integration technician whose job it is to be on hand to assist whenever they are needed. So if you need the fanatic support of the kind that Andy Murray&#8217;s mother provides, we will do our best. We don&#8217;t operate a ticketing system where you would have to to raise a support request and then await a response. Customers have the direct telephone number of the integration technician, which they can call at any time.</p>
<p>As well as the human support, we have developed a comprehensive range of<a href="http://www.textmarketer.co.uk/developers/restful-api.htm"> SMS API integration documents</a>. The documentation, along with code examples are designed and set out in a straightforward and logical way. We often find that with our support, successfully completing SMS API integration is far less of a hassle than originally anticipated.</p>
<p>We always provide a <a href="http://www.textmarketer.co.uk/signUpGoogle/">free testing account</a> for software developers and you will also receive as many free test credits as you need, whether that&#8217;s just a few or a few thousand. if you would like to explore our SMS API, please feel free to <a href="http://www.textmarketer.co.uk/signUpGoogle/">set up a free account</a>. You will automatically receive 10 free to credits but just drop us a quick line if you need more.</p>
<img src="http://www.textmarketer.co.uk/wordpress/?ak_action=api_record_view&id=3648&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.textmarketer.co.uk/blog/2011/10/sms-marketing-ideas/sms-api-integration-%e2%80%93-you-choose-your-level-of-support/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ruby on rails send sms example</title>
		<link>http://www.textmarketer.co.uk/blog/2011/05/technical/ruby-on-rails-send-sms-example/</link>
		<comments>http://www.textmarketer.co.uk/blog/2011/05/technical/ruby-on-rails-send-sms-example/#comments</comments>
		<pubDate>Wed, 11 May 2011 09:42:20 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.textmarketer.co.uk/blog/?p=2628</guid>
		<description><![CDATA[Example Code for sending SMS via Ruby on Rails &#160; This example code snip it uses the sandbox so your sms wont actually get sent. To make it live change the site parameter, also dont forget to update your username and password parameters. Send SMS example Get the number of &#8230; <a href="http://www.textmarketer.co.uk/blog/2011/05/technical/ruby-on-rails-send-sms-example/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h1>Example Code for sending SMS via Ruby on Rails</h1>
<p>&nbsp;</p>
<p>This example code snip it uses the sandbox so your sms wont actually get sent. To make it live change the site parameter, also dont forget to update your username and password parameters.</p>
<p><a href="http://www.textmarketer.co.uk/blog/wp-content/uploads/2011/05/ruby_send_sms_example.rtf">Send SMS example</a></p>
<p><a href="http://www.textmarketer.co.uk/blog/wp-content/uploads/2011/05/ruby_get_credits.rtf">Get the number of credits remaining</a></p>
<p>&nbsp;</p>
<img src="http://www.textmarketer.co.uk/wordpress/?ak_action=api_record_view&id=2628&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.textmarketer.co.uk/blog/2011/05/technical/ruby-on-rails-send-sms-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>REST SMS Gateway API  groups resource</title>
		<link>http://www.textmarketer.co.uk/blog/2011/04/business-sms/rest-sms-gateway-api-%e2%80%93-groups-resource/</link>
		<comments>http://www.textmarketer.co.uk/blog/2011/04/business-sms/rest-sms-gateway-api-%e2%80%93-groups-resource/#comments</comments>
		<pubDate>Thu, 07 Apr 2011 15:14:37 +0000</pubDate>
		<dc:creator>Jay</dc:creator>
				<category><![CDATA[Business SMS]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.textmarketer.co.uk/blog/?p=2438</guid>
		<description><![CDATA[groups &#160; This blog post has been superseded with our website documentation This resource allows you list send groups. This document is referred to by the REST SMS Gateway API &#8211; Specification Document. Resource URI: http://www.textmarketer.biz/services/rest/groups Actions relating to send groups. GET method - Used to list all available groups &#160; GET method Lists all &#8230; <a href="http://www.textmarketer.co.uk/blog/2011/04/business-sms/rest-sms-gateway-api-%e2%80%93-groups-resource/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div>
<div>
<h2><em><strong>groups</strong></em></h2>
<p>&nbsp;</p>
<p><a href="http://www.textmarketer.co.uk/developers/restful-api.htm">This blog post has been superseded with our website documentation</a></p>
<p>This resource allows you list send groups.</p>
<p>This document is referred to by the <a title="API specification" href="/blog/2010/03/business-sms/rest-sms-api-specification-document/">REST SMS Gateway API &#8211; Specification Document</a>.</p>
<p><em><strong>Resource URI:</strong></em></p>
<pre>http://www.textmarketer.biz/services/rest/groups</pre>
<p>Actions relating to send groups.</p>
<ul>
<li><a title="post method" href="#get">GET method</a> - Used to list all available groups</li>
</ul>
<p>&nbsp;</p>
<p><a id="get"></a><em><strong>GET method</strong></em></p>
<p>Lists all the available send groups, and the STOP groups.</p>
<p>Example usage:</p>
<pre>http://www.textmarketer.biz/services/rest/groups</pre>
<p>Example POST response:</p>
<pre id="line1">&lt;response processed_date="2011-04-07T14:43:59+01:00"&gt;
	&lt;groups quantity="2" &gt;
		&lt;group name="short_ZDZY" numbers="0" id="1" is_stop="true"/&gt;
		&lt;group name="MyGroup" numbers="0" id="2" is_stop="false"/&gt;
	&lt;/groups&gt;
&lt;/response&gt;</pre>
<ul>
<li>quantity &#8211; the number of groups</li>
<li>name &#8211; the group name</li>
<li>numbers &#8211; the quantity of numbers in the group</li>
<li>id &#8211; the group&#8217;s unique ID</li>
<li>is_stop &#8211; whether or not this is a STOP group</li>
</ul>
<p><a title="REST SMS API DTD specification and  documentation" href="http://www.textmarketer.biz/services/rest/DTD/" target="_self">Read the advanced specification of this response</a>.</p>
<p>&nbsp;</p>
<p>Example PHP code:</p>
<pre>
<div>Under development</div>
</pre>
<p>&nbsp;</p>
</div>
</div>
<p>&nbsp;</p>
<img src="http://www.textmarketer.co.uk/wordpress/?ak_action=api_record_view&id=2438&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.textmarketer.co.uk/blog/2011/04/business-sms/rest-sms-gateway-api-%e2%80%93-groups-resource/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>REST SMS Gateway API &#8211; group resource</title>
		<link>http://www.textmarketer.co.uk/blog/2011/04/sms-gateway/rest-sms-gateway-api-group-resource/</link>
		<comments>http://www.textmarketer.co.uk/blog/2011/04/sms-gateway/rest-sms-gateway-api-group-resource/#comments</comments>
		<pubDate>Thu, 07 Apr 2011 14:42:15 +0000</pubDate>
		<dc:creator>Jay</dc:creator>
				<category><![CDATA[All SMS Gateway Documentation]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.textmarketer.co.uk/blog/?p=2429</guid>
		<description><![CDATA[group This resource allows you to view and modify a send group. This blog post has been superseded with our website documentation This document is referred to by the REST SMS Gateway API &#8211; Specification Document. Resource URI: http://www.textmarketer.biz/services/rest/group Actions relating to send groups. POST method - Used to add number(s) to a group. &#160; &#8230; <a href="http://www.textmarketer.co.uk/blog/2011/04/sms-gateway/rest-sms-gateway-api-group-resource/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div>
<h2><em><strong>group</strong></em></h2>
<p>This resource allows you to view and modify a send group.<br />
<a href="http://www.textmarketer.co.uk/developers/restful-api.htm">This blog post has been superseded with our website documentation</a><br />
This document is referred to by the <a title="API specification" href="/blog/2010/03/business-sms/rest-sms-api-specification-document/">REST SMS Gateway API &#8211; Specification Document</a>.</p>
<p><em><strong>Resource URI:</strong></em></p>
<pre>http://www.textmarketer.biz/services/rest/group</pre>
<p>Actions relating to send groups.</p>
<ul>
<li><a title="post method" href="#post">POST method</a> - Used to add number(s) to a group.</li>
</ul>
<p>&nbsp;</p>
<p><a id="post"></a><em><strong>POST method</strong></em></p>
<p>Attempts to add a number or numbers to a group.</p>
<p>Example usage:</p>
<pre>http://www.textmarketer.biz/services/rest/group</pre>
<p>Post arguments:</p>
<table border="0">
<tbody>
<tr>
<td width="100px"><strong>parameter</strong></td>
<td><strong>usage</strong></td>
</tr>
<tr>
<td>id</td>
<td>the ID of the group to add to (optional &#8211; if you use &#8216;name&#8217; instead)</td>
</tr>
<tr>
<td>name</td>
<td>the name of the group to send to &#8211; case-sensitive (optional &#8211; if you use &#8216;id&#8217; instead)</td>
</tr>
<tr>
<td>numbers</td>
<td>a comma-separated list of numbers to add to the group</td>
</tr>
</tbody>
</table>
<p>NOTE: If you specify a group by it&#8217;s name, and the name is not unique, the first matched group will be used.</p>
<p>Example POST response:</p>
<pre id="line1">&lt;response processed_date="2011-04-07T14:57:00+01:00"&gt;
&lt;added quantity="1"&gt;
&lt;number&gt;447777000001&lt;/number&gt;
&lt;/added&gt;
&lt;stopped quantity="0"&gt;&lt;/stopped&gt;
&lt;duplicates quantity="1"&gt;
&lt;number&gt;447777000002&lt;/number&gt;
&lt;/duplicates&gt;
&lt;/response&gt;</pre>
<ul>
<li>quantity &#8211; the number of added/stopped/duplicate numbers</li>
<li>added &#8211; a list of numbers successfully added to the group</li>
<li>stopped &#8211; a list of numbers that were not added to the group since they are members of a STOP group</li>
<li>duplicates &#8211; a list of numbers that were not added to the group since they are already members of the group</li>
</ul>
<p><a title="REST SMS API DTD specification and  documentation" href="http://www.textmarketer.biz/services/rest/DTD/" target="_self">Read the advanced specification of this response</a>.</p>
<p>Specific error codes:</p>
<table border="0">
<tbody>
<tr>
<td width="100px"><strong>Code</strong></td>
<td><strong>Meaning</strong></td>
</tr>
<tr>
<td>0</td>
<td>the group ID or name was not specified or was invalid</td>
</tr>
<tr>
<td>1</td>
<td>group ID or name did not correspond to any known group</td>
</tr>
<tr>
<td>2</td>
<td>no numbers were supplied for adding to the group</td>
</tr>
<tr>
<td>3</td>
<td>a number was not of a valid format</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>Example XML error response:</p>
<pre id="line1">&lt;response processed_date="2011-04-07T15:04:19+01:00"&gt;
&lt;errors&gt;
	&lt;error code="1"&gt;Group not found&lt;/error&gt;
&lt;/errors&gt;
&lt;/response&gt;</pre>
<p>Example PHP code:</p>
<pre>
<div>&lt;?php</div>
<div>/**</div>
<div>* POST request on the 'group' resource (add numbers to group)</div>
<div>*/</div>
<div>$url = 'http://www.textmarketer.biz/services/rest/group';</div>
<div>// for testing:</div>
<div>$url = 'http://sandbox.textmarketer.biz/services/rest/group';</div>
<div>$username = 'myAPIusername'; // CHANGE THIS!!!</div>
<div>$password = 'myAPIpassword'; // CHANGE THIS!!!</div>
<div>$groupName = 'MyGroupName'; // CHANGE THIS!!</div>
<div>$numbersToAdd = '447777000001,447777000002'; // CHANGE THIS!!</div>
<div>$data = array('name'=&gt;$groupName, 'numbers'=&gt;'$numbersToAdd',</div>
<div>'username'=&gt;$username, 'password'=&gt;$password);</div>
<div>$data = http_build_query($data, '', '&amp;');</div>
<div>// we're using the curl library to make the request</div>
<div>$curlHandle = curl_init();</div>
<div>curl_setopt($curlHandle, CURLOPT_URL, $url);</div>
<div>curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);</div>
<div>curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $data);</div>
<div>curl_setopt($curlHandle, CURLOPT_POST, 1);</div>
<div>$responseBody = curl_exec($curlHandle);</div>
<div>$responseInfo  = curl_getinfo($curlHandle);</div>
<div>curl_close($curlHandle);</div>
<div></div>
<div>// deal with the response</div>
<div>if ($responseInfo['http_code']==200)</div>
<div>{</div>
<div>$xml_obj = simplexml_load_string($responseBody);</div>
<div>// do something with the result</div>
<div>$xml_added = $xml_obj-&gt;added;</div>
<div>$atts = $xml_added-&gt;attributes();</div>
<div>$added = (integer) $atts-&gt;quantity;</div>
<div>echo "$added added";</div>
<div>} else {</div>
<div>// handle the error here</div>
<div>var_dump($responseInfo);</div>
<div>var_dump($responseBody);</div>
<div>}</div>
<div>?&gt;</div>
</pre>
<p><span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace;"><span style="font-size: 12px; line-height: 18px; white-space: pre;"><br />
</span></span></p>
</div>
<img src="http://www.textmarketer.co.uk/wordpress/?ak_action=api_record_view&id=2429&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.textmarketer.co.uk/blog/2011/04/sms-gateway/rest-sms-gateway-api-group-resource/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java example code using our SMS gateway</title>
		<link>http://www.textmarketer.co.uk/blog/2011/03/technical/java-example-code-using-our-sms-gateway/</link>
		<comments>http://www.textmarketer.co.uk/blog/2011/03/technical/java-example-code-using-our-sms-gateway/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 09:02:33 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.textmarketer.co.uk/blog/?p=2353</guid>
		<description><![CDATA[The popular java language can be easily used to ineterace with our SMS API (sometimes known as gateway). To make life easier a simple example is attached below, this example sends SMS and reads back the responses. This blog post has been superseded with our website documentation Java SMS code example, click to download &#8230; <a href="http://www.textmarketer.co.uk/blog/2011/03/technical/java-example-code-using-our-sms-gateway/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The popular java language can be easily used to ineterace with our SMS API (sometimes known as gateway). To make life easier a simple example is attached below, this example sends SMS and reads back the responses.<br />
<a href="http://www.textmarketer.co.uk/developers/restful-api.htm">This blog post has been superseded with our website documentation</a></p>
<p><a href="http://www.textmarketer.co.uk/blog/wp-content/uploads/2011/03/Java_SMS.rtf">Java SMS code example, click to download</a></p>
<p><a href="http://www.textmarketer.co.uk/blog/2010/03/business-sms/rest-sms-api-specification-document/" target="_blank">The full API spec can be found here</a></p>
<img src="http://www.textmarketer.co.uk/wordpress/?ak_action=api_record_view&id=2353&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.textmarketer.co.uk/blog/2011/03/technical/java-example-code-using-our-sms-gateway/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>c# code example</title>
		<link>http://www.textmarketer.co.uk/blog/2011/03/technical/c-code-example/</link>
		<comments>http://www.textmarketer.co.uk/blog/2011/03/technical/c-code-example/#comments</comments>
		<pubDate>Mon, 07 Mar 2011 09:31:32 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.textmarketer.co.uk/blog/?p=2279</guid>
		<description><![CDATA[Attached is a C# example &#8211; a generic method called SendSMS() for calling the SMS Gateway service and an example of it being called. Included is XML parsing for the returned responses. The API spec can be found here Sending SMS using C#, example code]]></description>
			<content:encoded><![CDATA[<p><!-- p.p1 {margin: 0.0px 0.0px 12.0px 0.0px; font: 10.0px Arial} -->Attached is a C# example &#8211; a generic method called SendSMS() for calling the SMS Gateway service and an example of it being called. Included is XML parsing for the returned responses.</p>
<p><a href="http://www.textmarketer.co.uk/blog/2010/03/business-sms/rest-sms-api-specification-document/" target="_blank">The API spec can be found here</a></p>
<p><a href="http://www.textmarketer.co.uk/blog/wp-content/uploads/2011/03/CSharp_SMS1.rtf">Sending SMS using C#, example code</a></p>
<img src="http://www.textmarketer.co.uk/wordpress/?ak_action=api_record_view&id=2279&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.textmarketer.co.uk/blog/2011/03/technical/c-code-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multithreading PHP for sending SMS</title>
		<link>http://www.textmarketer.co.uk/blog/2011/03/technical/multi-threading-php-for-sending-sms/</link>
		<comments>http://www.textmarketer.co.uk/blog/2011/03/technical/multi-threading-php-for-sending-sms/#comments</comments>
		<pubDate>Wed, 02 Mar 2011 11:16:12 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[PHP Classes]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.textmarketer.co.uk/blog/?p=2239</guid>
		<description><![CDATA[On occasion we need to control a PHP script from a single script but allow it to execute several PHP instances. PHP it&#8217;s self doesn&#8217;t have any native ability to multithread, which I remember as being a bit of an irritant when I started using the language, but you can &#8230; <a href="http://www.textmarketer.co.uk/blog/2011/03/technical/multi-threading-php-for-sending-sms/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><!-- 		@page { margin: 2cm } 		P { margin-bottom: 0.21cm } 		A:link { so-language: zxx } -->On occasion we need to control a PHP script from a single script but allow it to execute several PHP instances.</p>
<p>PHP it&#8217;s self doesn&#8217;t have any native ability to <strong>multithread</strong>, which I remember as being a bit of an irritant when I started using the language,  but you can use a couple of tricks to achieve a similar result.</p>
<p>&nbsp;</p>
<p><strong>Consider this scenario</strong></p>
<p>Our SMS Gateway interface (or API) is accessed via an <a href="http://www.textmarketer.co.uk/blog/2010/03/business-sms/rest-sms-api-specification-document/" target="_blank">RESTful web service  (HTTP POST)</a> or our <a href="http://www.textmarketer.co.uk/blog/2009/05/sms-gateway/text-marketer-apigateway-spec/" target="_blank">simple HTTP GET api</a>, these services offer a simple way to integrate with us, however there are draw backs the main one being the speed at which you can send data to the interface in a serial fashion.</p>
<p>Imagine the following:  Lets assume you want to  send 10,000 text messages as fast as  possible to the api, your method would do something like the following:</p>
<ul>
<li>construct data (your fully formed HTTP request)</li>
<li>open port</li>
<li>write data</li>
<li>read response</li>
<li>close port</li>
<li>repeat 10,000 times</li>
</ul>
<p>&nbsp;</p>
<p>With PHP this process is carried out in a linear fashion in the context of a loop, now let&#8217;s look at the numbers:</p>
<p>Internet latency to the api is an assumed 10ms, which would put you somewhere in the UK</p>
<p>The &#8216;system&#8217; that is the speed at which we can read and write back to your script is .5 ms</p>
<p>Total process time is 105000 ms or 105 seconds .. but wouldn&#8217;t it be nice to go quicker??</p>
<p>&nbsp;</p>
<p>Now this is where in parallel or multi threading would come in handy, if we could kick say 5 of these processes off at once then we could send the same amount of texts in 105 / 5  which is 21 seconds and a vast improvement.</p>
<p>&nbsp;</p>
<p>So how can this be done?</p>
<p>&nbsp;</p>
<p>Say hello to the Curl Extension <a href="http://uk3.php.net/curl">http://uk3.php.net/curl</a> this isn&#8217;t necessarily included with your  vanilla build of PHP so you&#8217;ll need to compile it in. The Curl extension offers many extras for the PHP developer one of which will will use to do our multithreading.</p>
<p>&nbsp;</p>
<p>It is usually best to explain the idea by example, here &#8216;s a class called DoMultiThread that shows the basic idea</p>
<p>&nbsp;</p>
<p><span style="color: #ff0000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;">&lt;?php</span></span></span></p>
<p><span style="font-family: Monaco, monospace; font-size: xx-small;"><span style="color: #0000ff;">class </span><span style="color: #000000;">DoMultiThread {</span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"> </span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #808080;">//// i&#8217;m not going to simulate a 10,000 volume send but you can get the idea!</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #808080;">//  some dummy data an array of 5 names and numbers for constructing unique  messages</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #0000ff;">private </span><span style="color: #660000;">$names </span><span style="color: #000000;">= </span><span style="color: #0000ff;">array </span><span style="color: #000000;">(</span><span style="color: #0000ff;">array </span><span style="color: #000000;">(</span><span style="color: #008200;">&#8220;name&#8221; </span><span style="color: #000000;">=&gt; </span><span style="color: #008200;">&#8220;peter&#8221;</span><span style="color: #000000;">, </span><span style="color: #008200;">&#8220;number&#8221; </span><span style="color: #000000;">=&gt; </span><span style="color: #008200;">&#8220;077122345566&#8243; </span><span style="color: #000000;">), </span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #0000ff;">array </span><span style="color: #000000;">(</span><span style="color: #008200;">&#8220;name&#8221; </span><span style="color: #000000;">=&gt; </span><span style="color: #008200;">&#8220;fred&#8221;</span><span style="color: #000000;">, </span><span style="color: #008200;">&#8220;number&#8221; </span><span style="color: #000000;">=&gt; </span><span style="color: #008200;">&#8220;077122345567&#8243; </span><span style="color: #000000;">), </span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #0000ff;">array </span><span style="color: #000000;">(</span><span style="color: #008200;">&#8220;name&#8221; </span><span style="color: #000000;">=&gt; </span><span style="color: #008200;">&#8220;susan&#8221;</span><span style="color: #000000;">, </span><span style="color: #008200;">&#8220;number&#8221; </span><span style="color: #000000;">=&gt; </span><span style="color: #008200;">&#8220;077122345568&#8243; </span><span style="color: #000000;">), </span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #0000ff;">array </span><span style="color: #000000;">(</span><span style="color: #008200;">&#8220;name&#8221; </span><span style="color: #000000;">=&gt; </span><span style="color: #008200;">&#8220;jim&#8221;</span><span style="color: #000000;">, </span><span style="color: #008200;">&#8220;number&#8221; </span><span style="color: #000000;">=&gt; </span><span style="color: #008200;">&#8220;077122345569&#8243; </span><span style="color: #000000;">), </span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #0000ff;">array </span><span style="color: #000000;">(</span><span style="color: #008200;">&#8220;name&#8221; </span><span style="color: #000000;">=&gt; </span><span style="color: #008200;">&#8220;katie&#8221;</span><span style="color: #000000;">, </span><span style="color: #008200;">&#8220;number&#8221; </span><span style="color: #000000;">=&gt; </span><span style="color: #008200;">&#8220;077122345510&#8243; </span><span style="color: #000000;">) );</span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"> </span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #0000ff;">function </span><span style="color: #000000;">__contruct() {</span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"> </span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #808080;">/// function sets up and sends 5 simultaneous threads</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #808080;">/// returns an array of the 5 outputs</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #660000;">$output </span><span style="color: #000000;">= </span><span style="color: #660000;">$this</span><span style="color: #000000;">-&gt;execute ();</span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"> </span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"> </span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"> }</span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"> </span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #0000ff;">protected function </span><span style="color: #000000;">execute() {</span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"> </span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #660000;">$mh </span><span style="color: #000000;">= curl_multi_init ();</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #660000;">$handles </span><span style="color: #000000;">= </span><span style="color: #0000ff;">array </span><span style="color: #000000;">(); </span><span style="color: #808080;">/// will hold all our handle instances</span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"> </span></span></span></p>
<p><span style="color: #808080; font-family: Monaco, monospace; font-size: xx-small;">/// create our 5 threads, i wouldn&#8217;t advise trying many more</span></p>
<p><span style="color: #000000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"> </span></span></span></p>
<p><span style="font-family: Monaco, monospace; font-size: xx-small;"><span style="color: #0000ff;">foreach </span><span style="color: #000000;">( </span><span style="color: #660000;">$names </span><span style="color: #0000ff;">as </span><span style="color: #660000;">$item </span><span style="color: #000000;">) {</span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #808080;">// create a new single curl handle</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #660000;">$curl_handle </span><span style="color: #000000;">= curl_init ();</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #808080;">// our unique transaction / message</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #660000;">$url </span><span style="color: #000000;">= </span><span style="color: #008200;">&#8220;http://www.textmarketer.biz/gateway/?username=user&amp;password=pass&amp;message=Hi &#8221; </span><span style="color: #000000;">. </span><span style="color: #660000;">$item </span><span style="color: #000000;">[</span><span style="color: #008200;">'name'</span><span style="color: #000000;">] . </span><span style="color: #008200;">&#8220;&amp;orig=test&amp;number=&#8221; </span><span style="color: #000000;">. </span><span style="color: #660000;">$item </span><span style="color: #000000;">[</span><span style="color: #008200;">'number'</span><span style="color: #000000;">];</span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"> </span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #808080;">// setting several options like url, timeout, returntransfer</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> curl_setopt ( </span><span style="color: #660000;">$curl_handle</span><span style="color: #000000;">, CURLOPT_URL, </span><span style="color: #660000;">$url </span><span style="color: #000000;">);</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> curl_setopt ( </span><span style="color: #660000;">$curl_handle</span><span style="color: #000000;">, CURLOPT_HEADER, </span><span style="color: #ff0000;">0 </span><span style="color: #000000;">);</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> curl_setopt ( </span><span style="color: #660000;">$curl_handle</span><span style="color: #000000;">, CURLOPT_RETURNTRANSFER, </span><span style="color: #0000ff;">true </span><span style="color: #000000;">);</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> curl_setopt ( </span><span style="color: #660000;">$curl_handle</span><span style="color: #000000;">, CURLOPT_TIMEOUT, </span><span style="color: #ff0000;">30 </span><span style="color: #000000;">);</span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"> </span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #808080;">// add to the curl multi handle, this allows us to do the multi threading</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> curl_multi_add_handle ( </span><span style="color: #660000;">$mh</span><span style="color: #000000;">, </span><span style="color: #660000;">$curl_handle </span><span style="color: #000000;">);</span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"> </span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #808080;">// we will need to access the indvidual handles later</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #660000;">$handles </span><span style="color: #000000;">[] = </span><span style="color: #660000;">$curl_handle</span><span style="color: #000000;">;</span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"> }</span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"> </span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #808080;">// execute the multi handle</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #660000;">$running </span><span style="color: #000000;">= null;</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #0000ff;">do </span><span style="color: #000000;">{</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> curl_multi_exec ( </span><span style="color: #660000;">$mh</span><span style="color: #000000;">, </span><span style="color: #660000;">$running </span><span style="color: #000000;">);</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #808080;">// it&#8217;s a good idea to reduce load, here it&#8217;s 1 micro second</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> usleep ( </span><span style="color: #ff0000;">10000 </span><span style="color: #000000;">);</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> } </span><span style="color: #0000ff;">while </span><span style="color: #000000;">( </span><span style="color: #660000;">$running </span><span style="color: #000000;">&gt; </span><span style="color: #ff0000;">0 </span><span style="color: #000000;">);</span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"> </span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #808080;">// get the content of the transaction, this will contain (in our case) things like the transaction id, credits remaining etc</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #0000ff;">for</span><span style="color: #000000;">(</span><span style="color: #660000;">$i </span><span style="color: #000000;">= </span><span style="color: #ff0000;">0</span><span style="color: #000000;">; </span><span style="color: #660000;">$i </span><span style="color: #000000;">&lt; count ( </span><span style="color: #660000;">$handles </span><span style="color: #000000;">); </span><span style="color: #660000;">$i </span><span style="color: #000000;">++) {</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #808080;">// get the content of the handle</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #660000;">$output </span><span style="color: #000000;">[] = curl_multi_getcontent ( </span><span style="color: #660000;">$handles </span><span style="color: #000000;">[</span><span style="color: #660000;">$i</span><span style="color: #000000;">] );</span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"> </span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #808080;">// remove the handle from the multi handle</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> curl_multi_remove_handle ( </span><span style="color: #660000;">$mh</span><span style="color: #000000;">, </span><span style="color: #660000;">$handles </span><span style="color: #000000;">[</span><span style="color: #660000;">$i</span><span style="color: #000000;">] );</span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"> }</span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"> </span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #808080;">// close the multi curl handle to free system resources</span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> curl_multi_close ( </span><span style="color: #660000;">$mh </span><span style="color: #000000;">);</span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"> </span></span></span></p>
<p><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"><span style="color: #000000;"> </span><span style="color: #0000ff;">return </span><span style="color: #660000;">$output</span><span style="color: #000000;">;</span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"> </span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;"> }</span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monaco, monospace;"><span style="font-size: xx-small;">}</span></span></span></p>
<p><span style="color: #ff0000; font-family: Monaco, monospace; font-size: xx-small;">?&gt;</span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<img src="http://www.textmarketer.co.uk/wordpress/?ak_action=api_record_view&id=2239&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.textmarketer.co.uk/blog/2011/03/technical/multi-threading-php-for-sending-sms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SMS Visual C#.Net Console example</title>
		<link>http://www.textmarketer.co.uk/blog/2011/01/technical/sms-visual-c-net-console-example/</link>
		<comments>http://www.textmarketer.co.uk/blog/2011/01/technical/sms-visual-c-net-console-example/#comments</comments>
		<pubDate>Wed, 05 Jan 2011 15:12:59 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.textmarketer.co.uk/blog/?p=2102</guid>
		<description><![CDATA[Example Code Visual C#.Net Console application that demonstrates sending a SMS Message and getting the number of credits remaining using both POST and GET HTTP calls Application Notes: It uses the Sandbox server and the user must add his/her username and password. The program was written in Visual Studio 2010. &#8230; <a href="http://www.textmarketer.co.uk/blog/2011/01/technical/sms-visual-c-net-console-example/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Example Code</h2>
<p><!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Tahoma} -->Visual C#.Net Console application that demonstrates sending a SMS Message and getting the number of credits remaining using both POST and GET HTTP calls</p>
<p>Application Notes:</p>
<p><!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Tahoma} --></p>
<ul>
<li>It uses the Sandbox server and the user must add his/her username and password.</li>
<li> The program was written in Visual Studio 2010.</li>
</ul>
<p>Many thanks to Andy.</p>
<p><a href="http://www.textmarketer.co.uk/blog/wp-content/uploads/2011/01/TextMarketer.zip">Download Zip file</a></p>
<img src="http://www.textmarketer.co.uk/wordpress/?ak_action=api_record_view&id=2102&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.textmarketer.co.uk/blog/2011/01/technical/sms-visual-c-net-console-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Combining Email with SMS as a communication tool</title>
		<link>http://www.textmarketer.co.uk/blog/2010/11/technical/combining-email-with-sms-as-a-communication-tool/</link>
		<comments>http://www.textmarketer.co.uk/blog/2010/11/technical/combining-email-with-sms-as-a-communication-tool/#comments</comments>
		<pubDate>Fri, 12 Nov 2010 14:31:05 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.textmarketer.co.uk/blog/?p=1963</guid>
		<description><![CDATA[One of the issues with using SMS as a communication medium from a commercial stand point is that it&#8217;s very difficult to maintain the thread of the conversation using web based tools as SMS reply doesn&#8217;t contain the original message. For example an SMS is sent to a customer hopefully will reply &#8230; <a href="http://www.textmarketer.co.uk/blog/2010/11/technical/combining-email-with-sms-as-a-communication-tool/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One of the issues with using SMS as a communication medium from a commercial stand point is that it&#8217;s very difficult to maintain the thread of the conversation using web based tools as SMS reply doesn&#8217;t contain the original message. For example an SMS is sent to a customer hopefully will reply but perhaps in a few days time (by which time several other messages may have been sent) by which time you may have forgotten what the original message was, this is because their reply doesn&#8217;t contain the original message, i.e it&#8217;s not threaded.</p>
<p>Email however is a great tool to maintain a thread or conversation, but lacks the penetration that SMS has. To solve this issue at Text Marketer, we have developed a system that uses your standard email client (such as Outlook) to maintain a short conversation with a customer but the communication method is SMS.</p>
<p><strong>A real life example</strong></p>
<p>A recruitment company has several account managers responsible for various vacancies. A vacancy has arisen for a job in IT, the account manager (let&#8217;s call him Bill) selects 20 of his best candidates and sends the standard job ad via his email client to our Email to SMS gateway&#8230;&#8230;meanwhile another urgent vacancy has arisen and again Bill selects his top candidates and using email sends them the job ad as a text message. So at this point he has two vacancies sent out to say 40 people. The problem would now arise where by the candidate texts back saying something like &#8220;Can you send me more information&#8221;, but at this point how does Bill know which vacancy he is asking about? Traditinally he&#8217;d have to match up the mobile to the communication he had sent.</p>
<p>The Text Marketer system is different because it also contains the original message with the response, so Bill would see his original job ad, what time and date he sent it and then the response from the candidate with the time it was sent. Now when any candidate texts back he knows which job they are referring to. The system has a thread or conversation element to it, just like normal email. Bill can then just hit reply and send the next part of the communication (perhaps asking him to call in), his reply is automatically converted into SMS by our email gateway and the candidate receives Bill response.</p>
<p><strong>Documents:</strong></p>
<p><a title="email to sms gateway" href="http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/email-to-sms-gateway-service-from-text-marketer/" target="_blank">How to configure your email to send to Text Marketer</a></p>
<p>To set up threaded SMS call us on 117 924 9207</p>
<img src="http://www.textmarketer.co.uk/wordpress/?ak_action=api_record_view&id=1963&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.textmarketer.co.uk/blog/2010/11/technical/combining-email-with-sms-as-a-communication-tool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Legacy system integration for SMS using Email</title>
		<link>http://www.textmarketer.co.uk/blog/2010/11/technical/legacy-system-integration-for-sms-using-email/</link>
		<comments>http://www.textmarketer.co.uk/blog/2010/11/technical/legacy-system-integration-for-sms-using-email/#comments</comments>
		<pubDate>Fri, 05 Nov 2010 09:37:27 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.textmarketer.co.uk/blog/?p=1917</guid>
		<description><![CDATA[Many older systems make it difficult for the developer to use the standard SMS API over HTTP to trigger SMS alerts.  The solution we found was to use email as the transport for the SMS data, this means anyone with an understanding of SMTP or email clients can send SMS. &#8230; <a href="http://www.textmarketer.co.uk/blog/2010/11/technical/legacy-system-integration-for-sms-using-email/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Many older systems make it difficult for the developer to use the standard <a href="http://www.textmarketer.co.uk/blog/2010/03/business-sms/rest-sms-api-specification-document/" target="_blank">SMS API over HTTP</a> to trigger SMS alerts.  The solution we found was to use email as the transport for the SMS data, this means anyone with an understanding of SMTP or email clients can send SMS. To use the email gateway it cant be much simpler. Here&#8217;s an example:</p>
<pre>TO: &lt;mobile number&gt;@textmarketer.bz
SUBJECT: &lt;username&gt;%&lt;password&gt;

Hello World##</pre>
<p><strong>Simple!</strong><br />
The username and password is found in the API settings of your account. You can also set the originator (sender id) there as well, or if you want to set it on a message basis you just do the following:</p>
<pre>TO: @textmarketer.bz
SUBJECT: &lt;username&gt;%&lt;password&gt;
Hello World##
James#</pre>
<p>Would send an sms from &#8220;James&#8221;</p>
<p>Lastly if you want to send the same message to mulitple people the format changes somewhat</p>
<pre>TO: gateway@textmarketer.biz
SUBJECT: &lt;username&gt;%&lt;password&gt;
Hello World##
James#
 &lt;mobile number&gt;
 &lt;mobile number&gt;
 &lt;mobile number&gt;
</pre>
<p>As you can see this is a very simple system to use. The sms gateway will accept plain text or html emails so sending from outlook for example is supported. Also it is worth noting that the message can be 612 characters long as concatenation automatically occurs after 160 chars message length.</p>
<img src="http://www.textmarketer.co.uk/wordpress/?ak_action=api_record_view&id=1917&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.textmarketer.co.uk/blog/2010/11/technical/legacy-system-integration-for-sms-using-email/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Email-to-SMS Gateway service from Text Marketer</title>
		<link>http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/email-to-sms-gateway-service-from-text-marketer/</link>
		<comments>http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/email-to-sms-gateway-service-from-text-marketer/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 13:37:21 +0000</pubDate>
		<dc:creator>Jay</dc:creator>
				<category><![CDATA[All Bulk SMS Account Documentation]]></category>
		<category><![CDATA[All SMS Gateway Documentation]]></category>
		<category><![CDATA[Email to SMS]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[gateway]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[hotmail]]></category>
		<category><![CDATA[outlook]]></category>
		<category><![CDATA[send]]></category>
		<category><![CDATA[sms]]></category>

		<guid isPermaLink="false">http://87.106.109.73/blog/?p=1636</guid>
		<description><![CDATA[Please note that this blog page has been superseded with http://www.textmarketer.co.uk/developers/sms-email-gateway.htm  Our email-to-SMS service provides a simple way for you to send text messages via email. This is in addition to our simple HTTP SMS Gateway API, explained here, and we also provide a more complex RESTful SMS API to send SMS messages and &#8230; <a href="http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/email-to-sms-gateway-service-from-text-marketer/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Please note that this blog page has been superseded with<a href="http://www.textmarketer.co.uk/developers/sms-email-gateway.htm"> http://www.textmarketer.co.uk/developers/sms-email-gateway.htm </a></p>
<p>Our email-to-SMS service provides a simple way for you to send text messages via email.</p>
<p>This is in addition to our simple HTTP <a title="SMS Gateway API" href="/blog/2009/05/sms-gateway/text-marketer-apigateway-spec/">SMS Gateway API</a>, explained <a title="SMS Gateway API" href="/blog/2009/05/sms-gateway/text-marketer-apigateway-spec/">here</a>, and we also provide a more complex <a title="RESTful SMS API" href="/blog/2010/03/sms-gateway/restful-web-services-sms-api-overview/">RESTful SMS API</a> to send SMS messages and give you access to information about your <a title="Get an SMS account" href="http://www.textmarketer.co.uk/signUpGoogle/" target="_self">SMS marketing account</a> (dont have one? You need to have an <a title="Free SMS account" href="http://www.textmarketer.co.uk/signUpGoogle/">account</a>).</p>
<p><strong>There are 3 main ways to use the email to sms gateway;</strong></p>
<p>Option 1 &#8211; To send single emails/messages using domain authentication<br />
Option 2 &#8211; To send single emails/messages using username/password authentication<br />
Option 3 &#8211; To send messages to multiple recipients with a single email (and advanced features)</p>
<p>&nbsp;</p>
<h2><strong>Option 1 &#8211; Send single emails/messages using domain authentication</strong></h2>
<p>This option is used when you cannot or do not want to transmit your username and password in the subject field of the email. You set your sending domain in your account, e.g. mycompanyname.com which is what we use for validation when the email comes in. Only emails sent from the domain you set will be accepted (no generic email accounts like hotmail or gmail are acceptable).</p>
<p><strong>Step 1</strong> &#8211; enable domain authentication in your Text Marketer account. <strong>Go to Settings | Account Settings</strong> as shown below.</p>
<p><a href="http://www.textmarketer.co.uk/wordpress/wp-content/uploads/2010/06/Fullscreen-capture-18052011-100448.jpg"><img class="alignnone size-full wp-image-2718" title="Fullscreen capture 18052011 100448" src="http://www.textmarketer.co.uk/wordpress/wp-content/uploads/2010/06/Fullscreen-capture-18052011-100448.jpg" alt="" width="480" height="292" /></a></p>
<p>&nbsp;</p>
<p>Under &#8220;Email Gateway Settings&#8221; enter your domain name (<em>e.g. if your email address was richard@greens.com then your domain name is greens.com</em>) in the field and press <strong>submit </strong>(do not include the @ sign). The system will return an &#8216;updated&#8217; message.</p>
<p>Then, click <strong>change </strong>next to your domain name and make sure it turns from disabled to <span style="color: #ff0000;"><strong>Active </strong></span>(in red).</p>
<p><strong>Step 2</strong> &#8211; now you are ready to send a test message. Format the email address as [mobilenumber]@textmarketer.biz (for example, <a href="mailto:447777111999@textmarketer.biz">447777111999@textmarketer.biz</a>) and send it our gateway. Make sure you add ## to the end of the text in the body you want to send (this tells our system that this is the end of the text to send out and avoids sending things like signatures etc). You can change the message termination string by logging into your account and navigating to &#8220;settings&#8221; =&gt; &#8220;Account Settings&#8221;.<br />
You don&#8217;t have to put anything in the subject line as it&#8217;s not used.</p>
<p>Here&#8217;s an example message (note the ## added at the end of the text to be sent):</p>
<p><a href="http://www.textmarketer.co.uk/wordpress/wp-content/uploads/2010/06/Fullscreen-capture-18052011-095127.jpg"><img class="alignnone size-full wp-image-2715" title="Fullscreen capture 18052011 095127" src="http://www.textmarketer.co.uk/wordpress/wp-content/uploads/2010/06/Fullscreen-capture-18052011-095127.jpg" alt="" width="480" height="278" /></a></p>
<p>&nbsp;</p>
<h2><strong>Option 2 &#8211; To send single emails/messages using username/password authentication</strong></h2>
<p>This option is exactly the same as option 1 apart from you do not need to turn on domain authentication in your account and instead you use your API username and password in the subject field (formed like <em>username%password</em>) of the email for authentication. You can find your API username and password in your  account on the <strong>Settings | API Settings</strong> page.</p>
<p>So your email would look like this:</p>
<p><a href="http://www.textmarketer.co.uk/wordpress/wp-content/uploads/2010/06/Fullscreen-capture-18052011-095743.jpg"><img class="alignnone size-full wp-image-2716" title="Fullscreen capture 18052011 095743" src="http://www.textmarketer.co.uk/wordpress/wp-content/uploads/2010/06/Fullscreen-capture-18052011-095743.jpg" alt="" width="480" height="277" /></a></p>
<p>&nbsp;</p>
<h2><strong>Option 3 &#8211; To send messages to multiple recipients with a single email (and advanced features)</strong></h2>
<p><img class="alignnone size-full wp-image-1662" style="border: black 1px solid;" title="fullscreen-capture-01072010-143626bmp" src="http://www.textmarketer.co.uk/blog/wp-content/uploads/2010/06/fullscreen-capture-01072010-143626bmp.jpg" alt="fullscreen-capture-01072010-143626bmp" width="480" height="217" /></p>
<p>1. Create an email to the address shown above<br />
<strong>IMPORTANT</strong>: this must be the gateway[at]textmarketer.co.uk address, not a [number]@ style address or it will fail.<br />
2. Put your API username and password in the subject field with a % symbol in between (no spaces). You can find your API username and password in your  account on the Settings &gt; API Settings page but it is usually the same unless you&#8217;ve updated your login details.<br />
3. Type the text message you want to send and at the end put two hash symbols &#8220;##&#8221;<br />
4. Put 1 or many numbers in a single column underneath (it&#8217;s always best in international format but UK numbers starting 07&#8230;&#8230; are OK too).<br />
5. Send the email!</p>
<p><strong><br />
Expanded Instructions / Additional Features</strong></p>
<p>The Email-to-SMS (or email-to-text-message) service allows you to send SMS text messages via email. You must have an <a title="Get an SMS account" href="http://www.textmarketer.co.uk/signUpGoogle/" target="_self">SMS marketing account</a> (you can create a <a title="Free SMS account" href="http://www.textmarketer.co.uk/signUpGoogle/">free account here</a>) to send text messages via this service.</p>
<p>The actual email address of the email-to-SMS gateway is shown in the screenshot above (gateway@ and the domain is textmarketer.co.uk).</p>
<p>To send a text message to one or more mobile numbers, you will specify the message to send, and the numbers to send to, in an email. You then send the email to our email-to-sms gateway email address (using a specific format/structure).</p>
<p>Let&#8217;s say you want to send a text message containing &#8216;Call us for a quote&#8217; to the UK mobile number 07777123456. To do this your email contents would look like this:</p>
<pre>Call us for a quote##
07777123456</pre>
<p>The &#8216;##&#8217; characters simply tell us that this is the end of the message to be sent. And it&#8217;s followed by the mobile number. That&#8217;s it!</p>
<p><strong>IDENTIFICATION</strong></p>
<p>Your email will contain your account&#8217;s API username and password in the email <em>subject</em>. This allows us to verify your identity and deduct credits for the text messages sent from your account.</p>
<p>Your email subject should contain your API username, followed by &#8216;%&#8217;, followed by your API password (You can find your API username and password in your  account on the &#8216;Settings&#8217; &gt; &#8216;API Settings&#8217; page.), e.g.</p>
<pre>myAPIusername%myAPIpassword</pre>
<p><strong>Example</strong></p>
<p>So the complete email (subject and body) would look like this:</p>
<p>Email Subject:</p>
<pre>myAPIusername%myAPIpassword</pre>
<p>Email Body/Contents:</p>
<pre>Call us for a quote##
07777123456</pre>
<p><strong>MULTIPLE RECIPIENTS</strong></p>
<p>You want to send a text message via email to more than one mobile number? No problem! Simply list the numbers on separate lines, like this:</p>
<pre>Call us for a quote##
07777123456
07777123457</pre>
<p>Or put them on the same line, with commas in between to separate the numbers, like this:</p>
<pre>Call us for a quote##
07777123456,07777123457</pre>
<p><strong>MESSAGE WITH MULTIPLE LINES</strong></p>
<p>A message sent using the email-to-SMS gateway can contain more than more line. Simply ensure the message still ends with &#8216;##&#8217;, e.g.:</p>
<pre>Special offer this week on:
- black tights
- green shoes##
07777123456</pre>
<p><strong>FROM/SENDER ID</strong></p>
<p>The sender ID is the number/name that your text message will appear as being sent from. When using the email-to-text API this defaults to the sender ID that is set in your account settings (see the &#8216;Send SMS&#8217; &gt; &#8216;Default Sender ID&#8217; page). For example, you might want to set the sender ID as the name of your business, or perhaps to your own mobile number.</p>
<p>The sender ID can be any 16-digit number, or any text of up to 11 alpha-numeric characters.</p>
<p><strong>Example</strong></p>
<p>Let&#8217;s say you want to send the message &#8216;Special 2-for-1 offer this week&#8217; to the UK mobile number 07777123456, with a sender ID of &#8216;Fast Pizzas&#8217;. Your email body (contents) would look like this:</p>
<pre>Special 2-for-1 offer this week##
Fast Pizzas#
07777123456</pre>
<p>The sender ID is &#8216;terminated&#8217;, i.e. ends with, a single &#8216;#&#8217; character. It can appear before or after the message, so this works too:</p>
<pre>Fast Pizzas#
Special 2-for-1 offer this week##
07777123456</pre>
<p><strong>ERROR REPORTING</strong></p>
<p>If your email-to-SMS request is successful, with no errors or problems, you will not get any response (unless you&#8217;re using the Sandbox service). However, if there are any problems with the format of your email, or problems sending to any of the numbers you specify in the email, you will get a verbose email response with details of the problem(s) encountered.</p>
<p>Note that you will not get any response if your API username or password (included in the email subject) were incorrect, or did not contain the &#8216;%&#8217; character to separate them.</p>
<p><strong>TESTING/SANDBOX</strong></p>
<p>If you want to test the service without actually sending any text messages, there is a different email address to use for this purpose:</p>
<p>gateway-sandbox@ followed by the same domain: textmarketer.co.uk</p>
<p>It works in the same way as the normal service, except that no text messages will be sent and therefore no credit will be deducted from your account. Also, unlike the normal service, you will get a confirmation email telling you what message would have been sent, and to what numbers, if you had used the normal live service.</p>
<img src="http://www.textmarketer.co.uk/wordpress/?ak_action=api_record_view&id=1636&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/email-to-sms-gateway-service-from-text-marketer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>REST SMS Gateway API &#8211; keywords resource</title>
		<link>http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/rest-sms-gateway-api-keywords-resource/</link>
		<comments>http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/rest-sms-gateway-api-keywords-resource/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 13:48:01 +0000</pubDate>
		<dc:creator>Jay</dc:creator>
				<category><![CDATA[All SMS Gateway Documentation]]></category>
		<category><![CDATA[Business SMS]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://87.106.109.73/blog/?p=1545</guid>
		<description><![CDATA[This blog post has been superseded with our website documentation keywords This document is referred to by the REST SMS Gateway API &#8211; Specification Document. Resource URI: http://www.textmarketer.biz/services/rest/keywords/mykeyword Actions on the ShortCode keywords (see Short Code SMS Service). GET method &#8211; get the availability of a given keyword GET method Test whether the specified &#8230; <a href="http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/rest-sms-gateway-api-keywords-resource/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.textmarketer.co.uk/developers/restful-api.htm">This blog post has been superseded with our website documentation</a></p>
<h2><em><strong>keywords</strong></em></h2>
<p>This document is referred to by the <a title="API specification" href="/blog/2010/03/business-sms/rest-sms-api-specification-document/">REST SMS Gateway API &#8211; Specification Document</a>.</p>
<p><em><strong><span style="font-style: normal;"><span style="font-weight: normal;">Resource URI:</span></span></strong></em></p>
<pre>http://www.textmarketer.biz/services/rest/keywords/mykeyword</pre>
<p>Actions on the ShortCode keywords (see <a href="http://www.textmarketer.co.uk/shortcode_sms.htm" target="_blank">Short Code SMS Service</a>).</p>
<ul>
<li><a title="get method" href="#get">GET method</a> &#8211; get the availability of a given keyword</li>
</ul>
<p><a id="get"></a><em><strong>GET method</strong></em></p>
<p>Test whether the specified keyword is available on our ShortCode number.</p>
<p><a title="resource ID" href="/blog/2010/03/business-sms/rest-sms-api-specification-document/#resource_identifier">RESOURCE_ID</a>: the keyword of which to test the availability, e.g. &#8216;mykeyword&#8217; in the example above</p>
<p><strong>Example usage</strong></p>
<pre>http://www.textmarketer.biz/services/rest/keywords/buyit</pre>
<p>will test whether &#8216;buyit&#8217; is an available keyword.</p>
<p><strong>Example GET response</strong></p>
<pre>&lt;<span class="start-tag">response</span><span class="attribute-name"> processed_date</span>=<span class="attribute-value">"2010-05-06T13:43:18+02:00"</span>&gt;
&lt;<span class="start-tag">available</span>&gt;true&lt;/<span class="end-tag">available</span>&gt;
&lt;<span class="start-tag">recycle</span>&gt;false&lt;/<span class="end-tag">recycle</span>&gt;
&lt;/<span class="end-tag">response</span>&gt;</pre>
<p>The &lt;available&gt; tag shows whether the keyword is available (true/false) and the &lt;recycle&gt; tag shows whether the keyword<em> </em>is available through &#8216;recycling&#8217; a disused keyword, i.e. one that was in use previously.</p>
<p><a title="REST SMS API DTD specification and documentation" href="http://www.textmarketer.biz/services/rest/DTD/" target="_self">Read the advanced specification of this response</a>.</p>
<p><strong>Specific error codes</strong></p>
<p>N/A</p>
<p><strong>Example PHP code</strong></p>
<pre>&lt;?php
/**
 * GET request on the 'keywords' resource
 */
$url = 'http://www.textmarketer.biz/services/rest/keywords/mykeywordtest'; // CHANGE THIS!!!
$username = 'myAPIusername'; // CHANGE THIS!!!
$password = 'myAPIpassword'; // CHANGE THIS!!!
$url = "$url?username=$username&amp;password=$password";

// we're using the curl library to make the request
$curlHandle = curl_init();
curl_setopt($curlHandle, CURLOPT_URL, $url);
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
$responseBody = curl_exec($curlHandle);
$responseInfo  = curl_getinfo($curlHandle);
curl_close($curlHandle);

// deal with the response
if ($responseInfo['http_code']==200)
{
	$xml_obj = simplexml_load_string($responseBody);
	$available =  $xml_obj-&gt;available == 'true';
	$recycled =  $xml_obj-&gt;recycle == 'true';
	// do something with the result
	if ($available)
		echo "Available ";
	else
		echo "Unavailable ";

	if ($recycled)
		echo "(recycled)";

} else {
	// handle the error
	var_dump($responseBody);
}
?&gt;</pre>
<img src="http://www.textmarketer.co.uk/wordpress/?ak_action=api_record_view&id=1545&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/rest-sms-gateway-api-keywords-resource/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>REST SMS Gateway API &#8211; sms resource</title>
		<link>http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/rest-sms-gateway-api-sms-resource/</link>
		<comments>http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/rest-sms-gateway-api-sms-resource/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 13:44:59 +0000</pubDate>
		<dc:creator>Jay</dc:creator>
				<category><![CDATA[All SMS Gateway Documentation]]></category>
		<category><![CDATA[Business SMS]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://87.106.109.73/blog/?p=1541</guid>
		<description><![CDATA[This blog post has been superseded with our website documentation sms This resource deals with sending SMS to customer. This document is referred to by the REST SMS Gateway API &#8211; Specification Document. Resource URI: http://www.textmarketer.biz/services/rest/sms Actions relating to sending SMS messages. POST method - Used to send an SMS message. POST POST method Attempts &#8230; <a href="http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/rest-sms-gateway-api-sms-resource/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.textmarketer.co.uk/developers/restful-api.htm">This blog post has been superseded with our website documentation</a></p>
<h2><em><strong>sms</strong></em></h2>
<p>This resource deals with sending SMS to customer.</p>
<p>This document is referred to by the <a title="API specification" href="/blog/2010/03/business-sms/rest-sms-api-specification-document/">REST SMS Gateway API &#8211; Specification Document</a>.</p>
<p><em><strong><span style="font-style: normal;"><span style="font-weight: normal;">Resource URI:</span></span></strong></em></p>
<pre>http://www.textmarketer.biz/services/rest/sms</pre>
<p>Actions relating to sending SMS messages.</p>
<ul>
<li><a title="post method" href="#post">POST method</a> - Used to send an SMS message.</li>
</ul>
<p style="color:white">POST</p>
<p><a id="post"></a><em><strong>POST method</strong></em></p>
<p>Attempts to send the specified SMS message.</p>
<p>Example usage:</p>
<pre>http://www.textmarketer.biz/services/rest/sms</pre>
<p>Post arguments:</p>
<table border="0">
<tbody>
<tr>
<td width="100px"><strong>parameter</strong></td>
<td><strong>usage</strong></td>
</tr>
<tr>
<td>message</td>
<td>the content of the message to be sent, up to 612 characters (see <a title="SMS Message concatination" href="#concatination" target="_self">Concatination below</a>) in the GSM alphabet. The GSM alphabet is a subset of ISO-8859-1. The SMS GSM characters we can support is <a title="GSM Character Set" href="http://www.textmarketer.co.uk/blog/2009/07/bulk-sms/supported-and-unsupported-characters-in-text-messages-gsm-character-set/" target="_blank">documented here</a></td>
</tr>
<tr>
<td>mobile_number</td>
<td>the mobile number of the recipient, in international format, e.g. 447777777777</td>
</tr>
<tr>
<td>originator</td>
<td>a string or international mobile number of the sender to be displayed to the recipient</td>
</tr>
<tr>
<td>username*</td>
<td>(optional) required if not using HTTP Digest authentication</td>
</tr>
<tr>
<td>password*</td>
<td>(optional) required if not using HTTP Digest authentication</td>
</tr>
</tbody>
</table>
<p>* Can be found by logging in to your account, Settings-&gt;API Settings</p>
<p style="color:white">CONCATENATION</p>
<p><a id="concatination"></a><strong><em>CONCATENATION</em></strong></p>
<p>If you exceed 160 characters you automatically invoke concatenation sending, this has the following consequences: Each message consists of a 153 character chunk, i.e. no longer 160 chars; the extra characters are used to glue the messages together. Therefore a message that is 307 characters long will require 3 messages to send (153 + 153 + 1).</p>
<p>Example POST response:</p>
<pre>&lt;response processed_date="2010-03-23T10:31:39+00:00"&gt;
	&lt;message_id&gt;4172870907&lt;/message_id&gt;
	&lt;credits_used&gt;1&lt;/credits_used&gt;
&lt;/response&gt;</pre>
<ul>
<li>message_id &#8211; the unique message ID attributed to the sent SMS</li>
<li>credits_used &#8211; the number of credits used to send the SMS</li>
</ul>
<p><a title="REST SMS API DTD specification and  documentation" href="http://www.textmarketer.biz/services/rest/DTD/" target="_self">Read the advanced specification of this response</a>.</p>
<p>Specific error codes:</p>
<table border="0">
<tbody>
<tr>
<td width="100px"><strong>Code</strong></td>
<td><strong>Meaning</strong></td>
</tr>
<tr>
<td>0</td>
<td>message refused by the operator</td>
</tr>
<tr>
<td>1</td>
<td>bad username or password</td>
</tr>
<tr>
<td>2</td>
<td>no more credits</td>
</tr>
<tr>
<td>3</td>
<td>invalid originator or too long</td>
</tr>
<tr>
<td>4</td>
<td>invalid or missing originator</td>
</tr>
<tr>
<td>5</td>
<td>invalid message or too long</td>
</tr>
<tr>
<td>6</td>
<td>you do not have enough credits for this message</td>
</tr>
<tr>
<td>7</td>
<td>invalid message or missing</td>
</tr>
<tr>
<td>8</td>
<td>message contains unsupported characters (listed in error message)</td>
</tr>
<tr>
<td>9</td>
<td>invalid number or too short</td>
</tr>
<tr>
<td>10</td>
<td>invalid number or not an integer</td>
</tr>
</tbody>
</table>
<p style="color:white">CONCATENATION</p>
<p>Example XML error response:</p>
<pre><span style="color: #cc0000;"><span style="color: #000000;">&lt;response processed_date="2010-03-24T14:37:41+00:00"&gt;
&lt;errors&gt;
	&lt;error code="10"&gt;invalid number or not an integer&lt;/error&gt;
	&lt;error code="9"&gt;invalid number or too short&lt;/error&gt;
&lt;/errors&gt;
&lt;/response&gt;</span>

</span></pre>
<p>Example PHP code:</p>
<pre>&lt;?php
/**
 * POST request on the 'sms' resource (send an SMS)
 */
$url = 'http://www.textmarketer.biz/services/rest/sms';
//$url = 'http://sandbox.textmarketer.biz/services/rest/sms';

$username = 'myAPIusername'; // CHANGE THIS!!!
$password = 'myAPIpassword'; // CHANGE THIS!!!

$data = array('message'=&gt;'hello','mobile_number'=&gt;'447777123123', 'originator'=&gt;'me',
	'username'=&gt;$username, 'password'=&gt;$password);
$data = http_build_query($data, '', '&amp;');
// we're using the curl library to make the request
$curlHandle = curl_init();
curl_setopt($curlHandle, CURLOPT_URL, $url);
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $data);
curl_setopt($curlHandle, CURLOPT_POST, 1);
$responseBody = curl_exec($curlHandle);
$responseInfo  = curl_getinfo($curlHandle);
curl_close($curlHandle);

// deal with the response
if ($responseInfo['http_code']==200)
{
	$xml_obj = simplexml_load_string($responseBody);
	// do something with the result
	echo "Message ID: $xml_obj-&gt;message_id\n";
	echo "Credits used: $xml_obj-&gt;credits_used\n";

	var_dump($responseBody);

} else {
	// handle the error
	var_dump($responseInfo);
	var_dump($responseBody);
}
?&gt;</pre>
<p><strong>NOTE</strong></p>
<p>It is important to understand the difference between the status of a message in a <a title="Delivery Report" href="/blog/2010/06/sms-gateway/rest-sms-gateway-api-deliveryreport-resource/" target="_self">delivery report</a>, and getting a success or failure when using the API to send a message. A success response from the SMS send only confirms that the number and message appear to be in the correct format &#8211; this does not mean that the number actually exists, or that the message was received by the recipient. Delivery reports, however, confirm to you what has actually happened to the sent message. See the <a title="Delivery Reports" href="/blog/2010/06/sms-gateway/rest-sms-gateway-api-deliveryreport-resource/" target="_self">deliveryReport</a> resource.</p>
<img src="http://www.textmarketer.co.uk/wordpress/?ak_action=api_record_view&id=1541&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/rest-sms-gateway-api-sms-resource/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>REST SMS Gateway API &#8211; deliveryReport resource</title>
		<link>http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/rest-sms-gateway-api-deliveryreport-resource/</link>
		<comments>http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/rest-sms-gateway-api-deliveryreport-resource/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 13:37:15 +0000</pubDate>
		<dc:creator>Jay</dc:creator>
				<category><![CDATA[All SMS Gateway Documentation]]></category>
		<category><![CDATA[Business SMS]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://87.106.109.73/blog/?p=1535</guid>
		<description><![CDATA[This blog post has been superseded with our website documentation deliveryReport This document is referred to by the REST SMS Gateway API &#8211; Specification Document. Resource URI: http://www.textmarketer.biz/services/rest/deliveryReport Actions on a specific delivery report. GET method - Gets the contents of a delivery report An individual delivery report shows the current known status of all messages &#8230; <a href="http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/rest-sms-gateway-api-deliveryreport-resource/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.textmarketer.co.uk/developers/restful-api.htm">This blog post has been superseded with our website documentation</a></p>
<h2><em><em><strong>deliveryReport</strong></em></em></h2>
<p>This document is referred to by the <a title="API specification" href="/blog/2010/03/business-sms/rest-sms-api-specification-document/">REST SMS Gateway API &#8211; Specification Document</a>.</p>
<p><em><span style="font-style: normal;"><span style="font-weight: normal;">Resource URI:</span></span></em></p>
<pre>http://www.textmarketer.biz/services/rest/deliveryReport</pre>
<p>Actions on a specific delivery report.</p>
<ul>
<li><a title="get method" href="#get">GET method</a> - Gets the contents of a delivery report</li>
</ul>
<p>An individual delivery report shows the current known status of all messages sent on a given day, or for a particular campaign. Whereas the REST API resource <em><a title="deliveryReports resource" href="/blog/2010/06/business-sms/rest-sms-gateway-api-deliveryreports-resource/" target="_self">deliveryReport</a><strong><a title="deliveryReports resource" href="#deliveryReports_resource" target="_self">s</a> </strong></em>(note the trailing s) gets a list of available delivery report names, including delivery reports for campaigns (see <a title="deliveryReports resource" href="/blog/2010/06/business-sms/rest-sms-gateway-api-deliveryreports-resource/" target="_self">here</a>).</p>
<p style="color:white">GET</p>
<p><a id="get"></a><strong><em>GET method</em></strong></p>
<p>Gets the contents of a delivery report &#8211; the status of delivery of sent messages on a given day or for a given campaign.</p>
<p style="padding-left: 30px;">It is important to understand the difference between the status of a message in a delivery report, and getting a success or failure when using the API to <a title="sms resource" href="/blog/2010/03/business-sms/rest-sms-api-specification-document/#sms_resource" target="_self">send</a> a message.</p>
<p style="padding-left: 30px;">A &#8216;success&#8217; response from the SMS <a title="sms resource" href="/blog/2010/03/business-sms/rest-sms-api-specification-document/#sms_resource" target="_self">send</a> only confirms that the number and message appear to be in the correct format &#8211; this does not mean that the number actually exists, or that the message was received by the recipient.</p>
<p style="padding-left: 30px;">Whereas a delivery report &#8211; which you retrieve through this &#8216;deliveryReport&#8217; resource &#8211; confirms to you what has actually happened to the sent message. This may change over time, i.e. a delivery report may not show a status for a given message 10 minutes after the message was sent, but may show a status after an hour. The status of messages can change up to 24 hours after the message was sent. Therefore you may prefer to wait for 24 hours after sending an SMS before trying to retrieve its delivery report.</p>
<p style="padding-left: 30px;">The possible outcomes for a sent message in a delivery report are: DELIVERED,REJECTED,FAILED, &#8220;NON-UK&#8221;  or no report at all.</p>
<ul style="padding-left: 60px;">
<li>REJECTED means that the relevant operator rejected the message and did not attempt to deliver it.</li>
<li>FAILED probably means that the number does exist (or at least not anymore).</li>
<li>DELIVERED means the message was received on the handset.</li>
<li>&#8220;NON-UK&#8221; you are on a UK only route and have tried to send a non UK number.</li>
</ul>
<p style="padding-left: 30px;">Occasionally there is no delivery report status for a given message at all. This can be due to a failure at the operator end because of exceptionally high load or other problems.</p>
<p><strong>Example usage</strong></p>
<pre>http://www.textmarketer.biz/services/rest/deliveryReport/test-190310</pre>
<p>will get the contents of the delivery report named &#8216;test-190310&#8242;. This is the delivery report for the campaign you would have sent named &#8216;test&#8217;.</p>
<p><a title="resource ID" href="/blog/2010/03/business-sms/rest-sms-api-specification-document/#resource_identifier">RESOURCE_ID</a>: the name of the delivery report to retrieve</p>
<p><strong>Example GET response</strong></p>
<pre>&lt;response processed_date="2010-03-19T15:24:30+00:00"&gt;
	&lt;report name="test-190310" last_updated="2010-03-19T09:45:04+00:00" extension="csv"&gt;
		&lt;reportrow modified_date="2010-03-19T09:45:00+00:00" mobile_number="447123123456" message_id="12345678"
 status="DELIVERED"/&gt;
		&lt;reportrow modified_date="2010-03-19T09:45:00+00:00" mobile_number="447123123456" message_id="12345679"
 status="DELIVERED"/&gt;
	&lt;/report&gt;
&lt;/response&gt;</pre>
<p>The XML response contains individual reportrow&#8217;s that give the delivery status of an individual message.</p>
<ul>
<li>&#8216;message_id&#8217; is a unique ID for the message that was sent</li>
<li>&#8216;modified_date&#8217; is the last date the delivery status for that message ID was updated</li>
<li>&#8216;mobile_number&#8217; is the number the SMS was sent to</li>
</ul>
<p><a title="REST SMS API DTD specification and  documentation" href="http://www.textmarketer.biz/services/rest/DTD/" target="_self">Read the advanced specification of this response</a>.</p>
<p><strong>Specific error codes</strong></p>
<p><strong></strong>N/A</p>
<p><strong>Note</strong></p>
<p>When we receive a status report from the operator this gets added to a delivery report with a standardised name. The naming format is as follows:</p>
<p>GatewayAPI_DD-MM-YY where DD is the day in the month, MM is the month and YY is the year, each being in a 2-digit format.</p>
<p>So for example:</p>
<pre>GatewayAPI_04-01-09     is valid</pre>
<pre>GatewapAPI_12-12-09     is valid</pre>
<pre>GatewayAPI_1-1-9        is invalid</pre>
<p>Thus to get the delivery report for messages sent on 12th January 2010, you would use the URI:</p>
<pre>http://www.textmarketer.biz/services/rest/deliveryReport/GatewayAPI_12-01-10</pre>
<p><strong>Example PHP</strong></p>
<pre>&lt;?php
/**
 * GET request on the deliveryReport resource
 */
// TODO the URL will change according to the delivery report to retrieve...
$url = 'http://www.textmarketer.biz/services/rest/deliveryReport/myreportname'; // CHANGE THIS!!!
$username = 'myAPIusername'; // CHANGE THIS!!!
$password = 'myAPIpassword'; // CHANGE THIS!!!
$url = "$url?username=$username&amp;password=$password";

// we're using the curl library to make the request
$curlHandle = curl_init();
curl_setopt($curlHandle, CURLOPT_URL, $url);
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
$responseBody = curl_exec($curlHandle);
$responseInfo  = curl_getinfo($curlHandle);
curl_close($curlHandle);

// deal with the response
if ($responseInfo['http_code']==200)
{
	$xml_obj = simplexml_load_string($responseBody);

	$reportRows = array();
	foreach ($xml_obj-&gt;report-&gt;reportrow as $xml_reportRow)
	{
		$atts = $xml_reportRow-&gt;attributes();
		$mobile = (string) $atts-&gt;mobile_number;
		$updated = (string) $atts-&gt;last_updated;
		$msgID = (int) $atts-&gt;message_id;
		$status = (string) $atts-&gt;status;
		$reports[] = array('mobile'=&gt;$mobile, 'modified'=&gt;$updated, 'messageID'=&gt;$msgID, 'status'=&gt;$status);
	}
	// do something with the report details
	var_dump($reports);

} else {
	// handle the error
	var_dump($responseBody);
}

?&gt;</pre>
<img src="http://www.textmarketer.co.uk/wordpress/?ak_action=api_record_view&id=1535&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/rest-sms-gateway-api-deliveryreport-resource/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>REST SMS Gateway API &#8211; deliveryReports resource</title>
		<link>http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/rest-sms-gateway-api-deliveryreports-resource/</link>
		<comments>http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/rest-sms-gateway-api-deliveryreports-resource/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 13:28:16 +0000</pubDate>
		<dc:creator>Jay</dc:creator>
				<category><![CDATA[All SMS Gateway Documentation]]></category>
		<category><![CDATA[Business SMS]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://87.106.109.73/blog/?p=1530</guid>
		<description><![CDATA[This blog post has been superseded with our website documentation deliveryReports This document is referred to by the REST SMS Gateway API &#8211; Specification Document. Resource URI: http://www.textmarketer.biz/services/rest/deliveryReports Actions on the list of available delivery reports. GET method - Gets a list of available delivery report names The REST API resource deliveryReports (note the trailing &#8216;s&#8217;) &#8230; <a href="http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/rest-sms-gateway-api-deliveryreports-resource/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.textmarketer.co.uk/developers/restful-api.htm">This blog post has been superseded with our website documentation</a></p>
<h2>deliveryReports</h2>
<p>This document is referred to by the <a title="API specification" href="/blog/2010/03/business-sms/rest-sms-api-specification-document/">REST SMS Gateway API &#8211; Specification Document</a>.</p>
<p><em><strong><span style="font-style: normal;"><span style="font-weight: normal;">Resource URI:</span></span></strong></em></p>
<pre>http://www.textmarketer.biz/services/rest/deliveryReports</pre>
<p>Actions on the list of available delivery reports.</p>
<ul>
<li><a title="get method" href="#get">GET method</a> - Gets a list of available delivery report names</li>
</ul>
<p>The REST API resource <em>deliveryReport<strong>s </strong></em>(note the trailing &#8216;s&#8217;) performs actions on the list of available delivery report names, including delivery reports for campaigns.</p>
<p>A delivery report shows the current known status of all messages sent on a given day or for a particular campaign. To access the contents of a particular delivery report &#8211; which will contain the status of individual messages &#8211; you would use the <a title="deliveryReport resource" href="/blog/2010/06/sms-gateway/rest-sms-gateway-api-deliveryreport-resource/" target="_self">deliveryReport</a> resource instead - i.e. no trailing &#8216;s&#8217;.</p>
<p style="color:white">GET</p>
<p><a id="get"></a><em><strong>GET method</strong></em></p>
<p>Get the list of available delivery reports.</p>
<p><strong>Example usage</strong></p>
<pre>http://www.textmarketer.biz/services/rest/deliveryReports</pre>
<p><strong>Example GET response</strong></p>
<pre>&lt;response processed_date="2010-03-19T15:20:49+00:00"&gt;
	&lt;userdirectory&gt;aBcDeFgHiJkLmNoPqRsTuVwZ&lt;/userdirectory&gt;
	&lt;reports quantity="2" &gt;
		&lt;report name="test-190310" last_updated="2010-03-19T09:45:04+00:00" extension="csv"/&gt;
		&lt;report name="GatewayAPI_08-03-10" last_updated="2010-03-08T15:45:02+00:00" extension="csv"/&gt;
	&lt;/reports&gt;
&lt;/response&gt;</pre>
<p><a title="REST SMS API DTD specification and  documentation" href="http://www.textmarketer.biz/services/rest/DTD/" target="_self">Read the advanced specification of this response</a>.</p>
<p>When we receive a delivery report from the operator this gets added to a delivery report with a standardised name. The naming format is as follows: GatewayAPI_DD-MM-YY where DD is the day in the month, MM is the month and YY is the year, each being in a 2-digit format. So for example:</p>
<pre>GatewayAPI_04-01-09     is valid</pre>
<pre>GatewapAPI_12-12-09     is valid</pre>
<pre>GatewayAPI_1-1-9        is invalid</pre>
<p><strong>Specific error codes</strong></p>
<p>N/A</p>
<p><strong>Note</strong></p>
<p>Although it is expected that you will want to use the <em>deliveryReport</em> resource to get the contents of a delivery report, the response as shown above contains all the information necessary to download the delivery reports in csv format, if that is your preferred method. In this case each report can be accessed via the URL</p>
<pre>http://www.textmarketer.biz/DeliveryReports/[dir]/[filename]</pre>
<p>where</p>
<pre>[dir] = the user directory as found in the response above, i.e. in the above example aBcDeFgHiJkLmNoPqRsTuVwZ
[filename] = the name of the csv file to download, e.g. GatewayAPI_08-03-10.csv</pre>
<p>So the complete URL in this example would be:</p>
<pre>http://www.textmarketer.biz/DeliveryReports/aBcDeFgHiJkLmNoPqRsTuVwZ/GatewayAPI_08-03-10.csv</pre>
<p><strong>Example PHP code</strong></p>
<pre>&lt;?php
/**
 * GET request on the deliveryReports resource
 */
$url = 'http://www.textmarketer.biz/services/rest/deliveryReports';
$username = 'myAPIusername'; // CHANGE THIS!!!
$password = 'myAPIpassword'; // CHANGE THIS!!!
$url = "$url?username=$username&amp;password=$password";

// we're using the curl library to make the request
$curlHandle = curl_init();
curl_setopt($curlHandle, CURLOPT_URL, $url);
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
$responseBody = curl_exec($curlHandle);
$responseInfo  = curl_getinfo($curlHandle);
curl_close($curlHandle);

// deal with the response
if ($responseInfo['http_code']==200)
{
	$xml_obj = simplexml_load_string($responseBody);
	$atts = $xml_obj-&gt;reports-&gt;attributes();
	$num_reports = (int) $atts-&gt;quantity;

	if ($num_reports &gt; 0)
	{
		echo "$num_reports reports\n";
		$reports = array();
		foreach ($xml_obj-&gt;reports-&gt;report as $xml_report)
		{
			$atts = $xml_report-&gt;attributes();
			$name = (string) $atts-&gt;name;
			$updated = (string) $atts-&gt;last_updated;
			$reports[] = array('name'=&gt;$name, 'modified'=&gt;$updated);
		}
		// do something with the report details
		var_dump($reports);
	} else {
		echo 'No reports available';
	}
} else {
	// handle the error
	var_dump($responseBody);
}
?&gt;</pre>
<img src="http://www.textmarketer.co.uk/wordpress/?ak_action=api_record_view&id=1530&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/rest-sms-gateway-api-deliveryreports-resource/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>REST SMS Gateway API &#8211; credits resource</title>
		<link>http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/rest-sms-gateway-api-credits-resource/</link>
		<comments>http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/rest-sms-gateway-api-credits-resource/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 13:19:38 +0000</pubDate>
		<dc:creator>Jay</dc:creator>
				<category><![CDATA[All SMS Gateway Documentation]]></category>
		<category><![CDATA[Business SMS]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://87.106.109.73/blog/?p=1525</guid>
		<description><![CDATA[This blog post has been superseded with our website documentation credits This document is referred to by the REST SMS Gateway API &#8211; Specification Document. Resource URI: http://www.textmarketer.biz/services/rest/credits Actions on the account credits. GET method - get the number of credits currently available on your account POST method - transfer credits between accounts GET &#8230; <a href="http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/rest-sms-gateway-api-credits-resource/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.textmarketer.co.uk/developers/restful-api.htm">This blog post has been superseded with our website documentation</a></p>
<h2><em><strong>credits</strong></em></h2>
<p>This document is referred to by the <a title="API specification" href="/blog/2010/03/business-sms/rest-sms-api-specification-document/">REST SMS Gateway API &#8211; Specification Document</a>.</p>
<p>Resource URI:</p>
<pre>http://www.textmarketer.biz/services/rest/credits</pre>
<p>Actions on the account credits.</p>
<ul>
<li><a title="get" href="#get">GET method</a> <em>- </em>get the number of credits currently available on your account</li>
<li><a title="post" href="#post">POST method</a> - transfer credits between accounts</li>
</ul>
<p style="color:white">GET</p>
<p><a id="get"></a><em><strong>GET method</strong></em></p>
<p>Get the number of credits currently available on your account.</p>
<p><strong>Example usage</strong></p>
<pre>http://www.textmarketer.biz/services/rest/credits</pre>
<p><strong>Example GET response</strong></p>
<pre>&lt;<span class="start-tag">response</span><span class="attribute-name"> processed_date</span>=<span class="attribute-value">"2010-03-19T15:19:33+00:00"</span>&gt;
&lt;<span class="start-tag">credits</span>&gt;37&lt;/<span class="end-tag">credits</span>&gt;
&lt;/<span class="end-tag">response</span>&gt;</pre>
<p><a title="REST SMS API DTD specification and documentation" href="http://www.textmarketer.biz/services/rest/DTD/" target="_self">Read the advanced specification of this response</a>.</p>
<p><strong>Specific error codes</strong></p>
<p>N/A</p>
<p><strong>Example PHP code</strong></p>
<pre>&lt;?php
/**
 * GET request on the 'credits' resource
 */
$url = 'http://www.textmarketer.biz/services/rest/credits';
$username = 'myAPIusername'; // CHANGE THIS!!!
$password = 'myAPIpassword'; // CHANGE THIS!!!
$url = "$url?username=$username&amp;password=$password";

// we're using the curl library to make the request
$curlHandle = curl_init();
curl_setopt($curlHandle, CURLOPT_URL, $url);
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
$responseBody = curl_exec($curlHandle);
$responseInfo  = curl_getinfo($curlHandle);
curl_close($curlHandle);

// deal with the response
if ($responseInfo['http_code']==200)
{
	$xml_obj = simplexml_load_string($responseBody);
	$credits = (int) $xml_obj-&gt;credits;
	// do something with the result
	echo $credits;

} else {
	// handle the error
	var_dump($responseBody);
}

?&gt;</pre>
<p style="color:white">P</p>
<p><a id="post"></a><em><strong>POST method</strong></em></p>
<p>Transfer credits from the source/master account to the target/sub account.</p>
<p><strong>Example usage</strong></p>
<pre>http://www.textmarketer.biz/services/rest/credits</pre>
<p><strong>Post arguments</strong></p>
<table border="0">
<tbody>
<tr valign="top">
<td width="100px"><strong>parameter</strong></td>
<td><strong>usage</strong></td>
</tr>
<tr valign="top">
<td>quantity</td>
<td>the number of credits to transfer from the source account to the target account. Must be a positive integer.</td>
</tr>
<tr valign="top">
<td>target</td>
<td>the account number of the account to transfer the credits to (this can be found in the Settings &gt; Account Settings page in the Web interface)</td>
</tr>
<tr valign="top">
<td>username</td>
<td>(optional) required if not using HTTP Digest authentication &#8211; this is the username of the source/master account</td>
</tr>
<tr valign="top">
<td>password</td>
<td>(optional) required if not using HTTP Digest authentication &#8211; this is the password of the source/master account</td>
</tr>
</tbody>
</table>
<p style="color:white">or</p>
<p>OR you can specify the target account user name and password, rather than the target account number</p>
<table border="0">
<tbody>
<tr valign="top">
<td width="100px"><strong>parameter</strong></td>
<td><strong>usage</strong></td>
</tr>
<tr valign="top">
<td>quantity</td>
<td>the number of credits to transfer from the source account to the target account. Must be a positive integer.</td>
</tr>
<tr valign="top">
<td>target_username</td>
<td>this is the username of the target/sub account to transfer credits TO</td>
</tr>
<tr valign="top">
<td>target_password</td>
<td>this is the password of the target/sub account to transfer credits TO</td>
</tr>
<tr valign="top">
<td>username</td>
<td>(optional) required if not using HTTP Digest authentication &#8211; this is the username of the source/master account to transfer credits FROM</td>
</tr>
<tr valign="top">
<td>password</td>
<td>(optional) required if not using HTTP Digest authentication &#8211; this is the password of the source/master account to transfer credits FROM</td>
</tr>
</tbody>
</table>
<p style="color:white">Example POST</p>
<p><strong>Example POST response</strong></p>
<pre>&lt;response processed_date="2010-03-23T10:31:39+00:00"&gt;
	&lt;source_credits_before&gt;1000&lt;/source_credits_before&gt;
	&lt;source_credits_after&gt;900&lt;/source_credits_after&gt;
	&lt;target_credits_before&gt;0&lt;/target_credits_before&gt;
	&lt;target_credits_after&gt;100&lt;/target_credits_after&gt;
&lt;/response&gt;</pre>
<p><a title="REST SMS API DTD specification and documentation" href="http://www.textmarketer.biz/services/rest/DTD/" target="_self">Read the advanced specification of this response</a>.</p>
<p><strong>Specific error codes</strong></p>
<table border="0">
<tbody>
<tr valign="top">
<td width="100px"><strong>Code</strong></td>
<td><strong>Meaning</strong></td>
</tr>
<tr valign="top">
<td>0</td>
<td>there are insufficient credits available to transfer the specified quantity, or the specified quantity is not a positive number</td>
</tr>
<tr valign="top">
<td>1</td>
<td>the target account number specified is not a valid number or username/password combination does not refer to any known account</td>
</tr>
</tbody>
</table>
<p style="color:white">Example XML</p>
<p><strong>Example XML error response</strong></p>
<pre><span><span style="color: #cc0000;"><span style="color: #000000;">&lt;response processed_date="2010-03-24T14:37:41+00:00"&gt;
&lt;errors&gt;
	&lt;error code="0"&gt;Invalid number of credits specified: -1&lt;/error&gt;
	&lt;error code="1"&gt;Invalid destination account number&lt;/error&gt;
&lt;/errors&gt;
&lt;/response&gt;</span></span></span></pre>
<p><strong>Example PHP code</strong></p>
<pre>&lt;?php
/**
 * POST request on the 'credits' resource (credit transfer)
 */
$url = 'http://www.textmarketer.biz/services/rest/credits';
// uncomment for testing:
//$url = 'http://sandbox.textmarketer.biz/services/rest/credits';
$username = 'myAPIusername'; // CHANGE THIS!!! - the username of the account you're transferring FROM
$password = 'myAPIpassword'; // CHANGE THIS!!!
$targetAccountNumber = 0; // CHANGE THIS!!

$data = array('quantity'=&gt;'1',
	'target'=&gt;$targetAccountNumber,
	// or you could use the target username/password instead of 'target'
	// 'target_username'=&gt;$targetUserName, 'target_password'=&gt;$targetPassword,
	'username'=&gt;$username, 'password'=&gt;$password);
$data = http_build_query($data, '', '&amp;');
// we're using the curl library to make the request
$curlHandle = curl_init();
curl_setopt($curlHandle, CURLOPT_URL, $url);
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $data);
curl_setopt($curlHandle, CURLOPT_POST, 1);
$responseBody = curl_exec($curlHandle);
$responseInfo  = curl_getinfo($curlHandle);
curl_close($curlHandle);

// deal with the response
if ($responseInfo['http_code']==200)
{
	$xml_obj = simplexml_load_string($responseBody);
	// do something with the result
	echo "Source account credits before: $xml_obj-&gt;source_credits_before\n";
	echo "Source account credits after: $xml_obj-&gt;source_credits_after\n";
	echo "Target account credits before: $xml_obj-&gt;target_credits_before\n";
	echo "Target account credits after: $xml_obj-&gt;target_credits_after\n";
} else {
	// handle the error here
	var_dump($responseInfo);
	var_dump($responseBody);
}
?&gt;</pre>
<img src="http://www.textmarketer.co.uk/wordpress/?ak_action=api_record_view&id=1525&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.textmarketer.co.uk/blog/2010/06/sms-gateway/rest-sms-gateway-api-credits-resource/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RESTful Web Services SMS Gateway API Overview</title>
		<link>http://www.textmarketer.co.uk/blog/2010/03/sms-gateway/restful-web-services-sms-api-overview/</link>
		<comments>http://www.textmarketer.co.uk/blog/2010/03/sms-gateway/restful-web-services-sms-api-overview/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 10:57:26 +0000</pubDate>
		<dc:creator>Jay</dc:creator>
				<category><![CDATA[All SMS Gateway Documentation]]></category>
		<category><![CDATA[Business SMS]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Web to SMS]]></category>
		<category><![CDATA[gateway]]></category>
		<category><![CDATA[integrate]]></category>
		<category><![CDATA[RESTful]]></category>
		<category><![CDATA[sms]]></category>
		<category><![CDATA[sms api]]></category>
		<category><![CDATA[web service]]></category>

		<guid isPermaLink="false">http://87.106.109.73/blog/?p=1107</guid>
		<description><![CDATA[This blog post has been superseded with our website documentation In addition to our simple HTTP SMS Gateway API, explained here, we also provide a &#8216;RESTful&#8217; SMS API to give you access to information about your SMS marketing account (don&#8217;t have one? Create a free account). If you are familiar with REST APIs, &#8230; <a href="http://www.textmarketer.co.uk/blog/2010/03/sms-gateway/restful-web-services-sms-api-overview/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.textmarketer.co.uk/developers/restful-api.htm">This blog post has been superseded with our website documentation</a></p>
<p>In addition to our simple HTTP <a title="SMS Gateway API" href="/blog/2009/05/sms-gateway/text-marketer-apigateway-spec/">SMS Gateway API</a>, explained <a title="SMS Gateway API" href="/blog/2009/05/sms-gateway/text-marketer-apigateway-spec/">here</a>, we also provide a &#8216;RESTful&#8217; SMS API to give you access to information about your <a title="Get an SMS account" href="http://www.textmarketer.co.uk/signUpGoogle/" target="_self">SMS marketing account</a> (don&#8217;t have one? Create a <a title="Free SMS account" href="http://www.textmarketer.co.uk/signUpGoogle/">free account</a>).</p>
<p>If you are familiar with REST APIs, you may wish to jump to our <a title="REST SMS API specification" href="/blog/2010/03/business-sms/rest-sms-api-specification-document/" target="_self">REST API specification document</a>.</p>
<p><strong>WHAT&#8217;S A &#8216;RESTful&#8217; SMS API?</strong></p>
<p>REST is a term used to describe a type of two-way communication via the Internet. It is an architectural style, not a standard, but makes use of well-known web technologies such as <a title="HTTP Protocol" href="http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol" target="_blank">HTTP</a>, <a title="XML Language" href="http://en.wikipedia.org/wiki/Xml" target="_blank">XML</a> and <a title="MIME types" href="http://en.wikipedia.org/wiki/Mime_types" target="_blank">MIME types</a>. For more information about REST APIs, read <a title="REST Web Services" href="http://www.xfront.com/REST-Web-Services.html" target="_blank">this great description of REST</a>.</p>
<p>At its most simple, our <a title="RESTful Web Services" href="http://http://www.xfront.com/REST-Web-Services.html" target="_blank">RESTful</a> SMS API allows you to request (&#8216;GET&#8217;) information. For example, from this &#8216;resource&#8217;</p>
<p><a title="REST SMS API resource example" href="http://www.textmarketer.biz/services/rest/credits" target="_blank"><em></em></a><em><a title="Credits resource" href="http://www.textmarketer.biz/services/rest/credits" target="_blank">http://www.textmarketer.biz/services/rest/credits</a> </em></p>
<p>you can access the number of credits available in your account. The response is an XML document that looks like this:</p>
<pre>&lt;<span class="start-tag">response</span><span class="attribute-name"> processed_date</span>=<span class="attribute-value">"2010-03-19T09:37:26+00:00"</span>&gt;
&lt;<span class="start-tag">credits</span>&gt;37&lt;/<span class="end-tag">credits</span>&gt;
&lt;/<span class="end-tag">response</span>&gt;</pre>
<p>The SMS REST API is that simple!</p>
<p><strong>WHAT ABOUT SECURITY?</strong></p>
<p>Although it&#8217;s not apparent from the example above, the interface does require authentication using your SMS API account username/password. We provide two ways of passing this information to the server.</p>
<p>The first is via <a title="HTTP Basic Auth" href="http://en.wikipedia.org/wiki/Basic_access_authentication" target="_blank">HTTP Basic Authentication</a>, which is demonstrated by the login box that appears if you click on the resource link above. HTTP Basic authentication can of course be handled within your code. However if you prefer a simpler method, you can pass the parameters via the URL as GET arguments, e.g.</p>
<p><em><a>http://www.textmarketer.biz/services/rest/credits?username=myusername&amp;password=mypassword</a></em></p>
<p>It is also recommended that you use encrypted communication with the REST Web Services by accessing resources via the HTTPS protocol (<em><a>https://&#8230; etc.)</a></em>.</p>
<p><strong>HOW DOES THE RESTful API HANDLE ERRORS?</strong></p>
<p>An advantage of using a RESTful API is that the underlying technologies already do a lot of the work for us. All responses via the HTTP protocol include headers that give us some information about the response. The headers in the above example would look like this:</p>
<pre>Date: Fri, 19 Mar 2010 10:11:40 GMT
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.2.11 ZendServer/4.0
Content-Length: 272
Connection: close
Content-Type: application/xml

200 OK</pre>
<p>The MIME type (Content-Type) is set to application/xml which identifies the type of content in the response. It is followed by the response status code &#8217;200&#8242; and the status message &#8216;OK&#8217;. This is a standard response to a successful request.</p>
<p>If we had tried to access a resource which didn&#8217;t exist, e.g.</p>
<p><a title="Bad request" href="http://www.textmarketer.biz/services/rest/anotherResource" target="_blank">http://www.textmarketer.biz/services/rest/anotherResource</a></p>
<p>we would get the following response headers:</p>
<pre>Date: Fri, 19 Mar 2010 10:18:23 GMT
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.2.11 ZendServer/4.0
Content-Length: 549
Connection: close
Content-Type: application/xml

404 Not Found :  (ERR101)</pre>
<p>The status code is 404, which is the HTTP protocol&#8217;s standard code for &#8216;resource not found&#8217;. The status message also contains some additional debugging information (ERR91) which you can ignore.</p>
<p>In addition to the status code, the response body contains XML detailing the error. In this example it might look like this:</p>
<pre>&lt;<span class="start-tag">response</span><span class="attribute-name"> processed_date</span>=<span class="attribute-value">"2010-03-24T14:45:54+00:00"</span>&gt;
&lt;<span class="start-tag">errors</span>&gt;
	&lt;<span class="start-tag">error</span><span class="attribute-name"> code</span>=<span class="attribute-value">"404"</span>&gt;Not Found :  (ERR101)&lt;/<span class="end-tag">error</span>&gt;
&lt;/<span class="end-tag">errors</span>&gt;
&lt;/<span class="end-tag">response</span>&gt;</pre>
<p>Thus, you can check the header status code for an error code, as well  as the response body.</p>
<p><strong>WHAT RESOURCES CAN I ACCESS THROUGH THE REST SMS API?</strong></p>
<p>At the moment, the resource URIs available to you are:</p>
<ul>
<li><a title="Credits resource" href="/blog/2010/03/business-sms/rest-sms-api-specification-document/#credits_resource"><em>http://www.textmarketer.biz/services/rest/credits</em></a> &#8211; to get the credits available on your account / transfer credits between accounts</li>
<li><a title="deliveryReports resource" href="/blog/2010/03/business-sms/rest-sms-api-specification-document/#deliveryReports_resource"><em>http://www.textmarketer.biz/services/rest/deliveryReports</em></a> &#8211; to list your delivery reports</li>
<li><a title="deliveryReport resource" href="/blog/2010/03/business-sms/rest-sms-api-specification-document/#deliveryReport_resource"><em>http://www.textmarketer.biz/services/rest/deliveryReport/</em>a_report_name</a> &#8211; to access the details of a specific report</li>
<li><a title="sms resource" href="/blog/2010/03/business-sms/rest-sms-api-specification-document/#sms_resource"><em>http://www.textmarketer.biz/services/rest/sms</em></a> &#8211; to send an SMS</li>
<li><em><a title="keywords resource" href="/blog/2010/03/business-sms/rest-sms-api-specification-document/#keywords_resource">http://www.textmarketer.biz/services/rest/keywords</a></em> &#8211; to get the availability of a given keyword (see <a href="http://www.textmarketer.co.uk/shortcode_sms.htm" target="_blank">Short Code SMS Service</a>)</li>
</ul>
<p>More will be added in the future.</p>
<p>Here are 2 walk-through examples for using the REST SMS API.</p>
<p><strong>EXAMPLE REQUEST 1 &#8211; GET CREDITS</strong></p>
<p>Make an HTTP GET request like this:</p>
<p><em></em><em><a>http://www.textmarketer.biz/services/rest/credits?username=myAPIusername&amp;password=myAPIpassword</a></em></p>
<p>Obviously, replace &#8216;myAPIusername&#8217; and &#8216;myAPIpassword&#8217; in the URL with the ones you received when you <a title="Sign up for free SMS account" href="http://www.textmarketer.co.uk/signUpGoogle/" target="_blank">signed up</a>.</p>
<p>When you send this request using your favorite programming language, you should receive the following HTTP <em>headers</em> in response:</p>
<pre>Date: Wed, 24 Mar 2010 15:17:28 GMT
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.2.11 ZendServer/4.0
Content-Length: 272
Connection: close
Content-Type: application/xml

200 OK</pre>
<p>Using your programming language, you can easily extract the status code (200 in this case), which indicates success (200) or failure (not 200). The status code of 200 here shows us the request was successful, i.e. the response contains the number of credits in your account.</p>
<p>Thus the HTTP response <em>body</em> that you receive will contain XML similar to this:</p>
<pre>&lt;<span class="start-tag">response</span><span class="attribute-name"> processed_date</span>=<span class="attribute-value">"2010-03-24T15:17:28+00:00"</span>&gt;
&lt;<span class="start-tag">credits</span>&gt;10&lt;/<span class="end-tag">credits</span>&gt;
&lt;/<span class="end-tag">response</span>&gt;</pre>
<p>In your programming language you can parse the XML to extract the value of the credits, in this case 10.</p>
<p>But if, for example, you use an incorrect password, the response headers will look like this:</p>
<pre>Date: Wed, 24 Mar 2010 15:30:10 GMT
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.2.11 ZendServer/4.0
Content-Length: 377
Connection: close
Content-Type: application/xml

403 Forbidden : Your username/password combination did not match an account. (ERR145)</pre>
<p>The 403 status code shows that an error occurred (all codes except 200 indicate an error). And the XML response body will also contain:</p>
<pre>&lt;<span class="start-tag">response</span><span class="attribute-name"> processed_date</span>=<span class="attribute-value">"2010-03-24T15:29:22+00:00"</span>&gt;
&lt;<span class="start-tag">errors</span>&gt;
	&lt;<span class="start-tag">error</span><span class="attribute-name"> code</span>=<span class="attribute-value">"403"</span>&gt;Forbidden : Your username/password combination did not match an account. (ERR145)&lt;/<span class="end-tag">error</span>&gt;
&lt;/<span class="end-tag">errors</span>&gt;
&lt;/<span class="end-tag">response</span>&gt;</pre>
<p><strong>EXAMPLE REQUEST 2 &#8211; SEND SMS</strong></p>
<p>In your programming language, create an HTTP <em>POST</em> request to this URL:</p>
<p><em>http://www.textmarketer.biz/services/rest/sms</em></p>
<p>Since this is a POST request, you cannot pass the username and password via the URL, so you need to use HTTP Digest Authentication, or simply include these parameters along with the other POST parameters you&#8217;ll need:</p>
<ul>
<li>message=&#8217;my message&#8217;</li>
<li>originator=&#8217;me&#8217;</li>
<li>mobile_number=&#8217;447777777777&#8242;</li>
<li>username=&#8217;myAPIusername&#8217; (replace with your own &#8211; or skip this parameter and use HTTP Digest Authentication)</li>
<li>password=&#8217;myAPIpassword&#8217; (replace with your own &#8211; or skip this parameter and use HTTP Digest Authentication)</li>
</ul>
<p>POSTing an HTTP request using the above as POST parameters would send an SMS message of &#8216;my message&#8217; to the mobile number 447777777777 from &#8220;me&#8221;.</p>
<p>NOTE: It will not work to pass these parameters as GET arguments (e.g. by appending them to the URL); this is the principle of a REST API.</p>
<p>Your HTTP POST request should return something similar to the following response headers:</p>
<pre>Date: Wed, 24 Mar 2010 15:17:28 GMT
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.2.11 ZendServer/4.0
Content-Length: 272
Connection: close
Content-Type: application/xml

200 OK</pre>
<p>&#8230;the &#8217;200&#8242; status code showing that your request was successful. The HTTP response body will consist of XML containing the ID of the SMS sent as well as the number of credits used to send it:</p>
<pre>&lt;response processed_date="2010-03-23T10:31:39+00:00"&gt;
	&lt;message_id&gt;4172870907&lt;/message_id&gt;
	&lt;credits_used&gt;1&lt;/credits_used&gt;
&lt;/response&gt;</pre>
<p>If, however, there was a problem with your request parameters, for example you set mobile_number to &#8216;garbage&#8217;, you would get similar response headers to this:</p>
<pre>Date: Wed, 24 Mar 2010 15:30:10 GMT
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.2.11 ZendServer/4.0
Content-Length: 377
Connection: close
Content-Type: application/xml

404 Bad request</pre>
<p>And the response body would contain XML detailing the precise problems with your request, like this:</p>
<pre><span><span style="color: #cc0000;"><span style="color: #000000;">&lt;response processed_date="2010-03-24T14:37:41+00:00"&gt;
&lt;errors&gt;
	&lt;error code="10"&gt;invalid number or not an integer&lt;/error&gt;
	&lt;error code="9"&gt;invalid number or too short&lt;/error&gt;
&lt;/errors&gt;
&lt;/response&gt;
</span></span></span></pre>
<p>See the <a title="sms resource" href="http://www.textmarketer.co.uk/blog/2010/03/business-sms/rest-sms-api-specification-document/#sms_resource">specification of the sms resource</a> for more details of the possible error codes.</p>
<p><strong>TESTING/SANDBOX</strong></p>
<p>A <a title="Sandbox API" href="/blog/2010/03/business-sms/rest-sms-api-specification-document/#sandbox">sandbox service</a> is available for testing your code without changing your account or using any credits.</p>
<p><strong>MORE INFORMATION</strong></p>
<p>For detailed information about our RESTful SMS API, please see our <a title="REST SMS API specification" href="/blog/2010/03/business-sms/rest-sms-api-specification-document/" target="_self">REST  API specification document</a>.</p>
<p>For reference, a list of the DTDs that correspond to the  resources available can be <a title="Web Services DTDs" href="http://www.textmarketer.biz/services/rest/DTD/" target="_blank">found here</a>.</p>
<img src="http://www.textmarketer.co.uk/wordpress/?ak_action=api_record_view&id=1107&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.textmarketer.co.uk/blog/2010/03/sms-gateway/restful-web-services-sms-api-overview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>REST SMS Gateway API &#8211; Specification Document</title>
		<link>http://www.textmarketer.co.uk/blog/2010/03/business-sms/rest-sms-api-specification-document/</link>
		<comments>http://www.textmarketer.co.uk/blog/2010/03/business-sms/rest-sms-api-specification-document/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 10:57:16 +0000</pubDate>
		<dc:creator>Jay</dc:creator>
				<category><![CDATA[Business SMS]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[All SMS Gateway Documentation]]></category>
		<category><![CDATA[RESTful]]></category>
		<category><![CDATA[sms api]]></category>
		<category><![CDATA[specification]]></category>

		<guid isPermaLink="false">http://87.106.109.73/blog/?p=1134</guid>
		<description><![CDATA[This blog post has been superseded with our website documentation For an overview of what REST and our RESTful SMS API is all about you may like to read our RESTful SMS API Overview. If you prefer you can use the simple SMS gateway, rather than our RESTful implementation. To get straight into the details, &#8230; <a href="http://www.textmarketer.co.uk/blog/2010/03/business-sms/rest-sms-api-specification-document/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.textmarketer.co.uk/developers/restful-api.htm">This blog post has been superseded with our website documentation</a></p>
<p>For an overview of what REST and our RESTful SMS API is all about you may like to read our <a title="RESTful SMS API Overview" href="/blog/2010/03/sms-gateway/restful-web-services-sms-api-overview/" target="_self">RESTful SMS API Overview</a>.</p>
<p>If you prefer you can use the <a title="simple sms gateway" href="http://www.textmarketer.co.uk/blog/2009/05/sms-gateway/text-marketer-apigateway-spec/">simple SMS gateway</a>, rather than our RESTful implementation.</p>
<p><strong>To get straight into the details, jump to:</strong></p>
<p><a title="Quick Start SMS API" href="#quickstart" target="_self">Quick Start</a><br />
<a title="Error Codes" href="#error_codes">Error codes</a></p>
<p><a title="Sandbox for testing" href="#sandbox">Sandbox</a></p>
<p>You can preform the following actions using the REST web service:</p>
<ul>
<li>send an SMS (<a title="sms post" href="#sms_resource">sms post</a>)</li>
<li>get the number of credits available (<a title="credits get" href="/blog/2010/06/sms-gateway/rest-sms-gateway-api-credits-resource/#get">credits get</a>)</li>
<li>transfer credits from one account to another (<a title="credits post" href="/blog/2010/06/sms-gateway/rest-sms-gateway-api-credits-resource/#post">credits post</a>)</li>
<li>get a list of delivery reports (<a title="deliveryReports get" href="/blog/2010/06/business-sms/rest-sms-gateway-api-deliveryreports-resource/#get">deliveryReports get</a>)</li>
<li>get the contents of a specific delivery report (<a title="deliveryReport get" href="/blog/2010/06/sms-gateway/rest-sms-gateway-api-deliveryreport-resource/#get">deliveryReport get</a>)</li>
<li>check availability of a given keyword on our ShortCode number (<a title="keywords get" href="/blog/2010/06/sms-gateway/rest-sms-gateway-api-keywords-resource/#get">keywords get</a>)</li>
<li>check the names and IDs of your send groups (<a title="Groups GET" href="/blog/2011/04/sms-gateway/rest-sms-gateway-api-group-resource/">groups get</a>)</li>
<li>add number(s) to a send group (<a title="group post" href="/blog/2011/04/sms-gateway/rest-sms-gateway-api-group-resource/#post">group post</a>)</li>
</ul>
<h2><a title="The Resource Identifier" href="#resource_identifier">Specification of the resources</a></h2>
<ol>
<li><a href="#credits_resource">credits</a></li>
<li><a title="deliveryReports resource" href="#deliveryReports_resource">deliveryReports</a></li>
<li><a title="deliveryReport resource" href="#deliveryReport_resource">deliveryReport</a></li>
<li><a title="sms resource" href="#sms_resource">sms</a></li>
<li><a title="keywords resource" href="#keywords_resource">keywords</a></li>
<li><a title="group resource" href="#group_resource">group</a></li>
<li><a title="groups resource" href="#groups_resource">groups</a></li>
</ol>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>QUICK START</strong><br />
Three things are essentially needed to use the REST SMS API:</p>
<ol>
<li>Ability to make a HTTP request
<ul>
<li>e.g. to https://www.textmarketer.biz/services/rest/credits</li>
</ul>
</li>
<li>Ability to read the HTTP response headers
<ul>
<li>e.g. &#8217;200 OK&#8217;</li>
</ul>
</li>
<li>Ability to parse the XML response
<ul>
<li>e.g. &lt;<span class="start-tag">credits</span>&gt;37&lt;/<span class="end-tag">credits</span>&gt;</li>
</ul>
</li>
</ol>
<p><strong>The Request URI </strong><strong>Explained</strong></p>
<p>You will make the HTTP request to a request URI such as:</p>
<pre>https://www.textmarketer.biz/services/rest/credits</pre>
<p>The base request URI is thus composed of :</p>
<p>&#8216;<em><strong>https://www.textmarketer.biz/services/rest/</strong></em><em>&#8216;</em> + a string that denotes the resource to be accessed, e.g. &#8216;<em>credits</em>&#8216;, &#8216;<em>deliveryReports</em>&#8216;, etc.</p>
<p>You can use http instead of https, but https is recommended.</p>
<p>Note that cAsE matters, i.e. &#8216;<em>deliveryReports</em>&#8216; will work, whereas &#8216;<em>deliveryreports</em>&#8216; (lower case &#8216;r&#8217;) will return an error.</p>
<p>You must obviously identify yourself during the request. If you know how to handle HTTP <a href="http://en.wikipedia.org/wiki/Digest_access_authentication" target="_blank">Digest Authentication</a>, that is the preferred method of authentication.</p>
<p>Otherwise you should attach the following to the end of the resource URI:</p>
<pre>?username=myAPIusername&amp;password=myAPIpassword</pre>
<p>Or, in the case of a POST request, such as for sending an SMS, include the username/password parameters in the POST parameters (e.g. see <a title="sms post" href="#sms_resource">sms post</a>).</p>
<p>In our example, the complete URI that results is:</p>
<pre>https://www.textmarketer.biz/services/rest/credits?username=myAPIusername&amp;password=myAPIpassword</pre>
<p>And this should return XML containing the number of credits available on your account.</p>
<p><strong>The HTTP Response Headers</strong></p>
<p>The only vital part of the response headers that you need is the status code. <em>200</em> means a successful request, all other codes returned will be errors.</p>
<p>If you get an error, the status message may give you some extra information about the error. For more details about the error codes and their meanings, see <a title="Error Codes" href="#error_codes" target="_self">Error Codes</a> below.</p>
<p><strong>The XML response</strong></p>
<p>The structure of the XML response is generally quite simple. The response to our <em>credits</em> request example would look like this:</p>
<pre id="line1">&lt;<span class="start-tag">response</span><span class="attribute-name"> processed_date</span>=<span class="attribute-value">"2010-03-19T14:08:40+00:00"</span>&gt;
&lt;<span class="start-tag">credits</span>&gt;37&lt;/<span class="end-tag">credits</span>&gt;
&lt;/<span class="end-tag">response</span>&gt;</pre>
<p>Your preferred programming language will have a method for parsing the XML response to obtain the value.</p>
<p><strong>Example PHP code</strong></p>
<pre>&lt;?php
/**
 * GET request on the 'credits' resource
 */
$url = 'http://www.textmarketer.biz/services/rest/credits';
$username = 'myAPIusername'; // CHANGE THIS!!!
$password = 'myAPIpassword'; // CHANGE THIS!!!
$url = "$url?username=$username&amp;password=$password";

// we're using the curl library to make the request
$curlHandle = curl_init();
curl_setopt($curlHandle, CURLOPT_URL, $url);
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
$responseBody = curl_exec($curlHandle);
$responseInfo  = curl_getinfo($curlHandle);
curl_close($curlHandle);

// deal with the response
if ($responseInfo['http_code']==200)
{
	$xml_obj = simplexml_load_string($responseBody);
	$credits = (int) $xml_obj-&gt;credits;
	// do something with the result
	echo $credits;

} else {
	// handle the error
	var_dump($responseBody);
}

?&gt;</pre>
<p>See the <a title="REST SMS API Examples" href="http://www.textmarketer.co.uk/blog/2010/03/campaign-articles/dev/rest-sms-api-code-examples/" target="_self">REST API Code Examples</a> for some more example code that you can use.</p>
<p>That&#8217;s the end of the Quick Start. You know to send the request, check the status code is <em>200</em>, and then parse the XML according to its declared structure.</p>
<p style="color: white;">Error codes</p>
<p><strong>ERROR CODES</strong></p>
<p>The HTTP status codes returned by our REST SMS API follow normal HTTP conventions. An example of the HTTP response headers from a request to our REST API:</p>
<pre>Date: Wed, 24 Mar 2010 14:45:54 GMT
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.2.11 ZendServer/4.0
Content-Length: 317
Connection: close
Content-Type: application/xml

404 Not Found :  (ERR101)</pre>
<p>You see the status code, 404 on the last line. Their meaning of the status codes in the context of our REST SMS API are as follows:</p>
<table border="0">
<tbody>
<tr>
<td><strong>Code</strong></td>
<td><strong>Meaning</strong></td>
</tr>
<tr>
<td>200</td>
<td>OK. We were able to successfully execute the requested operation.</td>
</tr>
<tr>
<td>400</td>
<td>Bad request. There was a problem with your request data, see the status message for details.</td>
</tr>
<tr>
<td>403</td>
<td>You do not have sufficient rights to access the specified resource.</td>
</tr>
<tr>
<td>404</td>
<td>The resource specified could not be found.</td>
</tr>
<tr>
<td>405</td>
<td>The specified method (get, post, put or delete) is not allowed for this resource.</td>
</tr>
<tr>
<td>500</td>
<td>An unexpected error occurred.</td>
</tr>
<tr>
<td>501</td>
<td>The method requested has not been implemented.</td>
</tr>
<tr>
<td>503</td>
<td>Service Unavailable. The Web Service is not currently available to serve your request.</td>
</tr>
</tbody>
</table>
<p>This list is not exhaustive, any code from the <a title="HTTP status  codes" href="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes" target="_blank">complete list of HTTP status codes</a> may be returned.</p>
<p>IMPORTANT NOTE: Error 503 may be returned if you exceed a certain number of requests per minute. You will see an error message similar to: &#8220;Your 201 requests exceed the maximum allowed of 100 requests within 15 minute(s). Please try again later&#8221;. This to reduce load on our servers, in order to guarantee a good service to all our users.  <em>There is no restriction on SMS sends.</em></p>
<p>USEFUL NOTE: the HTTP status message may contain more specific information. If you encounter an unexpected error, the &#8216;(ERRnn)&#8217; found in the status message is useful in any reports you send us.</p>
<p>In addition to the status codes, an error will also produce an XML response containing details of the error. In this example the XML response might look like this:</p>
<pre>&lt;<span class="start-tag">response</span><span class="attribute-name"> processed_date</span>=<span class="attribute-value">"2010-03-24T14:45:54+00:00"</span>&gt;
&lt;<span class="start-tag">errors</span>&gt;
	&lt;<span class="start-tag">error</span><span class="attribute-name"> code</span>=<span class="attribute-value">"404"</span>&gt;Not Found :  (ERR101)&lt;/<span class="end-tag">error</span>&gt;
&lt;/<span class="end-tag">errors</span>&gt;
&lt;/<span class="end-tag">response</span>&gt;</pre>
<p>Some resources, such as <a title="sms resource" href="#sms_resource">http://www.textmarketer.biz/services/rest/sms</a>, have additional error codes specific to the resource. These are documented along with the description of the resource.</p>
<p style="color: white;">Resource Identifier</p>
<p><strong>THE RESOURCE IDENTIFIER</strong></p>
<p>The example of a resource identifier used previously was:</p>
<p><span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; font-size: 12px; white-space: pre;">https://www.textmarketer.biz/services/rest/credits</span></p>
<p>All our REST SMS Web Service resource identifiers take the general form:</p>
<pre>PROTOCOL://RESOURCE_NAMESPACE/RESOURCE_NAME[/RESOURCE_ID]</pre>
<p>where</p>
<pre>PROTOCOL = http|https
RESOURCE_NAMESPACE = www.textmarketer.biz/services/rest
RESOURCE_NAME = credits|deliveryReports|deliveryReport|sms|keywords|etc</pre>
<pre>RESOURCE_ID = an_ID (optional) which specifies a particular resource element, e.g. a specific delivery report</pre>
<p>e.g.</p>
<pre>https://www.textmarketer.biz/services/rest/deliveryReport/GatewayAPI_09-02-10</pre>
<p>will access a delivery report named &#8216;<em>GatewayAPI_09-02-10</em>&#8216;.</p>
<p style="color: white;">Resources</p>
<p><strong>RESOURCES</strong></p>
<p>The currently implemented resources are:</p>
<ol>
<li><a href="#credits_resource">credits</a></li>
<li><a title="deliveryReports resource" href="#deliveryReports_resource">deliveryReports</a></li>
<li><a title="deliveryReport resource" href="#deliveryReport_resource">deliveryReport</a></li>
<li><a title="sms resource" href="#sms_resource">sms</a></li>
<li><a title="keywords resource" href="#keywords_resource">keywords</a></li>
<li><a title="group resource" href="#group_resource">group</a></li>
<li><a title="groups resource" href="#groups_resource">groups</a></li>
</ol>
<p><em><strong>1. credits</strong></em></p>
<pre>http://www.textmarketer.biz/services/rest/credits</pre>
<ul>
<li>GET method -<em> </em>get the number of credits currently available on your account</li>
<li><em><span style="font-style: normal;">POST method</span> </em>- transfer credits between accounts</li>
</ul>
<p>See the <a title="credits resource" href="/blog/2010/06/sms-gateway/rest-sms-gateway-api-credits-resource/" target="_self">full description</a> of this resource for details.</p>
<p><em><strong>2. deliveryReports</strong></em></p>
<pre>http://www.textmarketer.biz/services/rest/deliveryReports</pre>
<ul>
<li>GET method - Gets a list of available delivery report names</li>
</ul>
<p>See the <a title="deliveryReports resource" href="/blog/2010/06/business-sms/rest-sms-gateway-api-deliveryreports-resource/" target="_self">full description</a> of this resource for details.</p>
<p><em><strong>3. deliveryReport</strong></em></p>
<pre>http://www.textmarketer.biz/services/rest/deliveryReport/test-190310</pre>
<ul>
<li>GET method - Gets the contents of a delivery report &#8211; the delivery status of sent messages for a given day/campaign.</li>
</ul>
<p>See the <a title="deliveryReport resource" href="/blog/2010/06/sms-gateway/rest-sms-gateway-api-deliveryreport-resource/" target="_self">full description</a> of this resource for details.</p>
<p>NOTE: An individual delivery report that is accessed using this resource shows the current known status of all messages sent on a given day, or for a particular campaign. The REST API resource <em><a title="deliveryReports resource" href="#deliveryReports_resource" target="_self">deliveryReport</a><strong><a title="deliveryReports resource" href="#deliveryReports_resource" target="_self">s</a> </strong></em>(note the trailing s) gets a list of available delivery report names, including delivery reports for campaigns (see <a title="deliveryReports resource" href="#deliveryReports_resource" target="_self">above</a>).</p>
<p><em><strong>4. sms</strong></em></p>
<pre>http://www.textmarketer.biz/services/rest/sms</pre>
<ul>
<li><strong><em>POST method</em></strong> - Used to send an SMS message.</li>
</ul>
<p>See the <a title="sms resource" href="/blog/2010/06/sms-gateway/rest-sms-gateway-api-sms-resource/" target="_self">full description</a> of this resource for details.</p>
<p><em><strong>5. keywords </strong></em></p>
<pre>http://www.textmarketer.biz/services/rest/keywords/mykeyword</pre>
<ul>
<li><strong><em>GET method</em></strong><strong> </strong>- get the availability of a given keyword (see <a href="http://www.textmarketer.co.uk/shortcode_sms.htm" target="_blank">Short Code SMS Service</a>)</li>
</ul>
<p>See the <a title="keywords resource" href="/blog/2010/06/sms-gateway/rest-sms-gateway-api-keywords-resource/" target="_self">full description</a> of this resource for details.</p>
<p><em><strong>6. group</strong></em></p>
<pre>http://www.textmarketer.biz/services/rest/group</pre>
<ul>
<li><strong><em>POST method</em></strong><strong> </strong>- add number(s) to a send group</li>
</ul>
<p>See the <a title="group resource" href="/blog/2011/04/sms-gateway/rest-sms-gateway-api-group-resource/">full description</a> of this resource for details.</p>
<p><em><strong>7. groups</strong></em></p>
<pre>http://www.textmarketer.biz/services/rest/groups</pre>
<ul>
<li><strong><em>GET method</em></strong><strong> </strong>- list the available send groups</li>
</ul>
<p>See the <a href="http://www.textmarketer.co.uk/blog/2011/04/sms-gateway/rest-sms-gateway-api-group-resource/">full description</a> of this resource for details.</p>
<p style="color: white;">Sandbox</p>
<p><strong>TESTING/SANDBOX</strong></p>
<p>A sandbox service is available to allow you to test your integration code without using any credits or executing any function that would modify the data in your account. The service is available at</p>
<p><a title="Sandbox" href="http://sandbox.textmarketer.biz/services/rest">http://sandbox.textmarketer.biz/services/rest</a></p>
<p>i.e. only the hostname changes from <em>www.textmarketer.biz</em> to <em>sandbox.textmarketer.biz</em> within the resource URI.</p>
<p>The sandbox will do the same validation of your request as the live REST API and return the appropriate errors, but will not perform any action that modifies your account data or your credits. Nor will it actually send any SMS messages, so no delivery report will be generated.</p>
<p>NOTE: Accesses to the sandbox is limited to a certain number of requests per minute &#8211; to reduce load on our servers &#8211; in order to guarantee a good service to all our users. Therefore you may prefer to use the Sandbox only to check that individual requests work correctly, rather than testing bulk SMS sends. There is no restriction on SMS sends on the live system.</p>
<img src="http://www.textmarketer.co.uk/wordpress/?ak_action=api_record_view&id=1134&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.textmarketer.co.uk/blog/2010/03/business-sms/rest-sms-api-specification-document/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>REST SMS API Code Examples</title>
		<link>http://www.textmarketer.co.uk/blog/2010/03/dev/rest-sms-api-code-examples/</link>
		<comments>http://www.textmarketer.co.uk/blog/2010/03/dev/rest-sms-api-code-examples/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 10:56:58 +0000</pubDate>
		<dc:creator>Jay</dc:creator>
				<category><![CDATA[All SMS Gateway Documentation]]></category>
		<category><![CDATA[Development Blog]]></category>
		<category><![CDATA[PHP Classes]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php5]]></category>
		<category><![CDATA[RESTful]]></category>
		<category><![CDATA[sms api]]></category>
		<category><![CDATA[support]]></category>

		<guid isPermaLink="false">http://87.106.109.73/blog/?p=1157</guid>
		<description><![CDATA[This blog post has been superseded with our website documentation In our REST API specification document we saw, in general terms, how to make a request to our REST SMS API and how to deal with the response. Here we provide you with some more concrete examples that you can copy &#38; paste! &#8230; <a href="http://www.textmarketer.co.uk/blog/2010/03/dev/rest-sms-api-code-examples/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.textmarketer.co.uk/developers/restful-api.htm">This blog post has been superseded with our website documentation</a></p>
<p>In our <a title="REST SMS API specification" href="/blog/2010/03/business-sms/rest-sms-api-specification-document/" target="_self">REST API specification document</a> we saw, in general terms, how to make a request to our REST SMS API and how to deal with the response. Here we provide you with some more concrete examples that you can copy &amp; paste!</p>
<p>NOTE: You will want to add additional error checking to the examples below.</p>
<p>In each of the languages used here we create a request, send it, receive the response, and parse its contents.</p>
<p><strong>PHP</strong></p>
<p>Example for getting the number of credits:</p>
<pre>$url = 'http://www.textmarketer.biz/services/rest/credits';
$username = 'myAPIusername'; // CHANGE THIS!!!
$password = 'myAPIpassword'; // CHANGE THIS!!!
$url = "$url?username=$username&amp;password=$password";

// we're using the curl library to make the request
$curlHandle = curl_init();
curl_setopt($curlHandle, CURLOPT_URL, $url);
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
$responseBody = curl_exec($curlHandle);
$responseInfo  = curl_getinfo($curlHandle);
curl_close($curlHandle);

// deal with the response
if ($responseInfo['http_code']==200)
{
	$xml_obj = simplexml_load_string($responseBody);
	$credits = (int) $xml_obj-&gt;credits;
	// do something with the result
	echo $credits;

} else {
	// handle the error
	var_dump($responseBody);
}</pre>
<p>Example for getting the list of delivery reports:</p>
<pre>$url = 'http://www.textmarketer.biz/services/rest/deliveryReports';
$username = 'myAPIusername'; // CHANGE THIS!!!
$password = 'myAPIpassword'; // CHANGE THIS!!!
$url = "$url?username=$username&amp;password=$password";

// we're using the curl library to make the request
$curlHandle = curl_init();
curl_setopt($curlHandle, CURLOPT_URL, $url);
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
$responseBody = curl_exec($curlHandle);
$responseInfo  = curl_getinfo($curlHandle);
curl_close($curlHandle);

// deal with the response
if ($responseInfo['http_code']==200)
{
	$xml_obj = simplexml_load_string($responseBody);
	$atts = $xml_obj-&gt;reports-&gt;attributes();
	$num_reports = (int) $atts-&gt;quantity;

	if ($num_reports &gt; 0)
	{
		echo "$num_reports reports\n";
		$reports = array();
		foreach ($xml_obj-&gt;reports-&gt;report as $xml_report)
		{
			$atts = $xml_report-&gt;attributes();
			$name = (string) $atts-&gt;name;
			$updated = (string) $atts-&gt;last_updated;
			$reports[] = array('name'=&gt;$name, 'modified'=&gt;$updated);
		}
		// do something with the report details
		var_dump($reports);
	} else {
		echo 'No reports available';
	}
} else {
	// handle the error
	var_dump($responseBody);
}</pre>
<p>Example for getting the details of a particular delivery report:</p>
<pre>// TODO the URL will change according to the delivery report to retrieve...
$url = 'http://www.textmarketer.biz/services/rest/deliveryReport/GatewayAPI_09-02-10';
$username = 'myAPIusername'; // CHANGE THIS!!!
$password = 'myAPIpassword'; // CHANGE THIS!!!
$url = "$url?username=$username&amp;password=$password";

// we're using the curl library to make the request
$curlHandle = curl_init();
curl_setopt($curlHandle, CURLOPT_URL, $url);
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
$responseBody = curl_exec($curlHandle);
$responseInfo  = curl_getinfo($curlHandle);
curl_close($curlHandle);

// deal with the response
if ($responseInfo['http_code']==200)
{
	$xml_obj = simplexml_load_string($responseBody);

	$reportRows = array();
	foreach ($xml_obj-&gt;report-&gt;reportrow as $xml_reportRow)
	{
		$atts = $xml_reportRow-&gt;attributes();
		$mobile = (string) $atts-&gt;mobile_number;
		$updated = (string) $atts-&gt;last_updated;
		$msgID = (int) $atts-&gt;message_id;
		$status = (string) $atts-&gt;status;
		$reports[] = array('mobile'=&gt;$mobile, 'modified'=&gt;$updated, 'messageID'=&gt;$msgID, 'status'=&gt;$status);
	}
	// do something with the report details
	var_dump($reports);

} else {
	// handle the error
	var_dump($responseBody);
}</pre>
<p>Example for sending an SMS:</p>
<pre>$url = 'http://www.textmarketer.biz/services/rest/sms';
$username = 'myAPIusername'; // CHANGE THIS!!!
$password = 'myAPIpassword'; // CHANGE THIS!!!

$data = array('message'=&gt;'hello','mobile_number'=&gt;'447777777777', 'originator'=&gt;'me',
	'username'=&gt;$username, 'password'=&gt;$password);
$data = http_build_query($data, '', '&amp;');
// we're using the curl library to make the request
$curlHandle = curl_init();
curl_setopt($curlHandle, CURLOPT_URL, $url);
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $data);
curl_setopt($curlHandle, CURLOPT_POST, 1);
$responseBody = curl_exec($curlHandle);
$responseInfo  = curl_getinfo($curlHandle);
curl_close($curlHandle);

// deal with the response
if ($responseInfo['http_code']==200)
{
	$xml_obj = simplexml_load_string($responseBody);
	// do something with the result
	echo "Message ID: $xml_obj-&gt;message_id\n";
	echo "Credits used: $xml_obj-&gt;credits_used\n";

	var_dump($responseBody);

} else {
	// handle the error
	var_dump($responseInfo);
	var_dump($responseBody);
}</pre>
<p>Example for transferring credits:</p>
<pre>
<div>&lt;?php</div>
<div>/**</div>
<div> * POST request on the 'credits' resource (credit transfer)</div>
<div> */</div>
<div>$url = '<a href="http://www.textmarketer.biz/services/rest/credits" target="_blank">http://www.textmarketer.biz/services/rest/credits</a>';</div>
<div>// for testing:</div>
<div>//$url = '<a href="http://sandbox.textmarketer.biz/services/rest/credits" target="_blank">http://sandbox.textmarketer.biz/services/rest/credits</a>';</div>
<div>$username = 'myAPIusername'; // CHANGE THIS!!! - the username of the account you're transferring FROM</div>
<div>$password = 'myAPIpassword'; // CHANGE THIS!!!</div>
<div>$targetAccountNumber = 0; // CHANGE THIS!!</div>
<div></div>
<div>$data = array('quantity'=&gt;'1','target'=&gt;$targetAccountNumber,</div>
<div><span>	</span>'username'=&gt;$username, 'password'=&gt;$password);</div>
<div>$data = http_build_query($data, '', '&amp;');</div>
<div>// we're using the curl library to make the request</div>
<div>$curlHandle = curl_init();</div>
<div>curl_setopt($curlHandle, CURLOPT_URL, $url);</div>
<div>curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);</div>
<div>curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $data);</div>
<div>curl_setopt($curlHandle, CURLOPT_POST, 1);</div>
<div>$responseBody = curl_exec($curlHandle);</div>
<div>$responseInfo  = curl_getinfo($curlHandle);</div>
<div>curl_close($curlHandle);</div>
<div></div>
<div>// deal with the response</div>
<div>if ($responseInfo['http_code']==200)</div>
<div>{</div>
<div> // success - you may want to read in the return data here to see how many credits were  left on each account</div>
<div></div>
<div>} else {</div>
<div><span>	</span>// handle the error here</div>
<div><span>	</span>// var_dump($responseInfo);</div>
<div><span>	</span>// var_dump($responseBody);</div>
<div>}</div>

?&gt;</pre>
<p>For more details on creating <a title="REST requests in PHP" href="http://www.gen-x-design.com/archives/making-restful-requests-in-php/" target="_blank">REST requests in PHP, see here</a>.</p>
<img src="http://www.textmarketer.co.uk/wordpress/?ak_action=api_record_view&id=1157&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.textmarketer.co.uk/blog/2010/03/dev/rest-sms-api-code-examples/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Example of a Delphi/Pascal Interface  for the Bulk SMS Gateway / API</title>
		<link>http://www.textmarketer.co.uk/blog/2010/02/technical/1045/</link>
		<comments>http://www.textmarketer.co.uk/blog/2010/02/technical/1045/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 10:28:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://87.106.109.73/blog/?p=1045</guid>
		<description><![CDATA[For more information regarding the bulk sending API click here. A code example for sending SMS via a Delphi Pascal language, thanks to Graham Murt for the example code. {******************************************************************************* * * * TextMarketer Delphi/Pascal Interface * * * ******************************************************************************** { example use: procedure TForm1.Button1Click(Sender: TObject); begin SendTextMarketerSms(username, password, sender, recipient, &#8230; <a href="http://www.textmarketer.co.uk/blog/2010/02/technical/1045/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a title="Bulk SMS API" href="http://www.textmarketer.co.uk/blog/2009/05/sms-gateway/text-marketer-apigateway-spec/" target="_blank">For more information regarding the bulk sending API click here.</a></p>
<p>A code example for sending SMS via a Delphi Pascal language, thanks to <a title="kernow-software" href="http://www.kernow-software.co.uk" target="_blank">Graham Murt</a> for the example code.</p>
<pre>
<pre>{*******************************************************************************
*                                                                              *
*                 TextMarketer Delphi/Pascal Interface                         *
*                                                                              *
********************************************************************************

{

  example use:

  procedure TForm1.Button1Click(Sender: TObject);
  begin
    SendTextMarketerSms(username, password, sender, recipient, message);
  end;

}

unit untTextMarketer;

interface

uses Classes, IdHttp;

const
  C_HTTP_URL  = 'http://www.textmarketer.biz/gateway/';

type
  TTextMarketerSMS = class
  private
    FHttp: TIdHttp;
    FPassword: string;
    FUsername: string;
  public
    constructor Create; virtual;
    destructor Destroy; override;
    function SendSms(AOriginator,
                     ANumber,
                     AMessage: string;
                     AXmlResponse: Boolean): string;
    property Username: string read FUsername write FUsername;
    property Password: string read FPassword write FPassword;
  end;

  function SendTextMarketerSms(AUsername, APassword, ASender, ANumber, AMessage: string): string;

implementation

uses SysUtils;

function SendTextMarketerSms(AUsername, APassword, ASender, ANumber, AMessage: string): string;
var
  ASms: TTextMarketerSMS;
begin
  ASms := TTextMarketerSMS.Create;
  try
    ASms.Username := AUsername;
    ASms.Password := APassword;
    Result := ASms.SendSms(ASender, ANumber, AMessage, True);
  finally
    ASms.Free;
  end;
end;

{ TTextMarketerSMS }

function UrlEncode(const DecodedStr: String): String;
var
  I: Integer;
begin
  Result := '';
  if Length(DecodedStr) &gt; 0 then
    for I := 1 to Length(DecodedStr) do
    begin
      if not (DecodedStr[I] in ['0'..'9', 'a'..'z',
                                       'A'..'Z', ' ']) then
        if DecodedStr[I] = '£' then
          Result := Result + '%C2%A3'
        else
          Result := Result + '%' + IntToHex(Ord(DecodedStr[I]), 2)
      else if not (DecodedStr[I] = ' ') then
        Result := Result + DecodedStr[I]
      else
        begin
          Result := Result + '%20'
        end;
    end;
end;

constructor TTextMarketerSMS.Create;
begin
  inherited;
  FHttp := TIdHTTP.Create(nil);
end;

destructor TTextMarketerSMS.Destroy;
begin
  FHttp.Free;
  inherited;
end;

function TTextMarketerSMS.SendSms(AOriginator, ANumber, AMessage: string;
  AXmlResponse: Boolean): string;
var
  AResult: Boolean;
  AParams: AnsiString;
  AResponse: TStringList;
begin
  AResponse := TStringList.Create;
  try
    AParams := '';
    AParams := AParams + ('?username='+FUsername);
    AParams := AParams + ('&amp;password='+FPassword);
    AParams := AParams + ('&amp;number='+ANumber);
    AParams := AParams + ('&amp;orig='+UrlEncode(AOriginator));
    AParams := AParams + ('&amp;message='+UrlEncode(AMessage));
    if AXmlResponse then AParams := AParams + ('&amp;option=xml');
    try
      Result := FHttp.Post(C_HTTP_URL+AParams, AResponse);
    except
      Result := '';
    end;
  finally
    AResponse.Free;
  end;
end;

end.</pre>
</pre>
<img src="http://www.textmarketer.co.uk/wordpress/?ak_action=api_record_view&id=1045&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.textmarketer.co.uk/blog/2010/02/technical/1045/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

