Winter Sale

15% Free SMS - find out more here

REST SMS Gateway API – group resource

  • Why not share:
  • Social sharing button for Facebook
  • Social sharing button for Linkedin
  • Social sharing button for Twitter
  • Social sharing button for Googleplus
  • Social sharing button for Pinterest

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 – Specification Document.

Resource URI:

http://api.textmarketer.co.uk/services/rest/group

Actions relating to send groups.

 

POST method

Attempts to add a number or numbers to a group.

Example usage:

http://api.textmarketer.co.uk/services/rest/group

Post arguments:

parameter usage
id the ID of the group to add to (optional – if you use ‘name’ instead)
name the name of the group to send to – case-sensitive (optional – if you use ‘id’ instead)
numbers a comma-separated list of numbers to add to the group

NOTE: If you specify a group by it’s name, and the name is not unique, the first matched group will be used.

Example POST response:

<response processed_date="2011-04-07T14:57:00+01:00">
<added quantity="1">
<number>447777000001</number>
</added>
<stopped quantity="0"></stopped>
<duplicates quantity="1">
<number>447777000002</number>
</duplicates>
</response>
  • quantity – the number of added/stopped/duplicate numbers
  • added – a list of numbers successfully added to the group
  • stopped – a list of numbers that were not added to the group since they are members of a STOP group
  • duplicates – a list of numbers that were not added to the group since they are already members of the group

Read the advanced specification of this response.

Specific error codes:

Code Meaning
0 the group ID or name was not specified or was invalid
1 group ID or name did not correspond to any known group
2 no numbers were supplied for adding to the group
3 a number was not of a valid format

 

Example XML error response:

<response processed_date="2011-04-07T15:04:19+01:00">
<errors>
	<error code="1">Group not found</error>
</errors>
</response>

Example PHP code:

<?php
/**
* POST request on the 'group' resource (add numbers to group)
*/
$url = 'http://api.textmarketer.co.uk/services/rest/group';
// for testing:
$url = 'http://sandbox.textmarketer.biz/services/rest/group';
$username = 'myAPIusername'; // CHANGE THIS!!!
$password = 'myAPIpassword'; // CHANGE THIS!!!
$groupName = 'MyGroupName'; // CHANGE THIS!!
$numbersToAdd = '447777000001,447777000002'; // CHANGE THIS!!
$data = array('name'=>$groupName, 'numbers'=>'$numbersToAdd',
'username'=>$username, 'password'=>$password);
$data = http_build_query($data, '', '&');
// 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
$xml_added = $xml_obj->added;
$atts = $xml_added->attributes();
$added = (integer) $atts->quantity;
echo "$added added";
} else {
// handle the error here
var_dump($responseInfo);
var_dump($responseBody);
}
?>


No related posts.

Latest posts