This command can be used to insert new numbers into your Textlocal contact groups.
https://api.txtlocal.com/create_contacts/
<?php // Account details $apiKey = urlencode('Your apiKey'); // Contact details $group_id = '123456'; $numbers = 447123456789 .",". 447987654321 ; // Prepare data for POST request $data = array('apikey' => $apiKey, 'group_id' => $group_id, 'numbers' => $numbers); // Send the POST request with cURL $ch = curl_init('https://api.txtlocal.com/create_contacts/'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); // Process your response here echo $response; ?>
<?php // Account details $apiKey = urlencode('Your apiKey'); // Contact details $group_id = '123456'; $numbers = urlencode('447123456789,447987654321'); // Prepare data for the request $data = 'apikey=' . $apiKey . '&group_id=' . $group_id; // Send the GET request with cURL $ch = curl_init('https://api.txtlocal.com/create_contacts/?' . $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); // Process your response here echo $response; ?>
<?php require('Textlocal.class.php'); $Textlocal = new Textlocal(false, false, 'your apiKey'); $contacts = array('447123456789','447987654321'); $group_id = 41029; $response = $Textlocal->createContacts($contacts, $group_id); print_r($response); ?>
numbers | Comma-delimited list of mobile numbers in international format (i.e. 447123456789). |
---|---|
Login Parameters (Additional Information) | |
apiKey | You can create these in your Messenger Control Panel (click here) for each application, and limit the usage of them by host IP Address. |
Optional Parameters | |
group_id | ID of the group. Can either be found within Messenger (in the "Reports" - "Advanced Reports" - "List of Group ID's" section) or by running the get_groups command. Additionally group 5 contains "contacts" |
Note: If you also need to insert custom fields, a first name for example, then the create_contacts_bulk command would need to be used instead.
{ "group_id":123456, "num_contacts":2, "contacts":[{ "number":"447123456789", "firstName":"", "lastName":"", "custom1":"", "custom2":"", "custom3":"", "linkTracking":"abc1/def123" "groupID":"123456", "id":1000000001 }, { "number":"447987654321", "firstName":"", "lastName":"", "custom1":"", "custom2":"", "custom3":"", "linkTracking":"abc1/def321" "groupID":"123456", "id":1000000002 }], "status":"success" }
<?xml version="1.0" encoding="UTF-8" ?> <response> <group_id>187865</group_id> <num_contacts>2</num_contacts> <contacts> <contact> <number>447123456789</number> <firstName></firstName> <lastName></lastName> <custom1></custom1> <custom2></custom2> <custom3></custom3> <groupID>123456</groupID> <trackingLink>abc1/def123</trackingLink> <id>1000000009</id> </contact> <contact> <number>447987654321</number> <firstName></firstName> <lastName></lastName> <custom1></custom1> <custom2></custom2> <custom3></custom3> <groupID>123456</groupID> <trackingLink>abc1/def321</trackingLink> <id>1000000009</id> </contact> </contacts> <status>success</status> </response>
Note: This request returns a Link Tracking parameter which can be used with a Survey Link to send out pre-created Survey's via our API.
Error Codes | |
10 | Invalid group ID. |
---|---|
25 | No group ID specified. |
55 | No numbers specified. |
56 | Invalid number(s) specified. They will not be created. |
51 | No valid numbers specified. |
202 | Invalid or Duplicate numbers specified |