This command can be used to insert up to 1500 new numbers into your Textlocal contact groups and will allow you to insert extra fields such as the contact's name.
https://api.txtlocal.com/create_contacts_bulk/
<?php // Account details $apiKey = urlencode('Your apiKey'); // Contact details $group_id = '123456'; $contacts = array(array('number' => 447123456789, 'first_name' => 'John', 'last_name' => 'Doe'), array('number' => 447987654321, 'first_name' => 'Lucy', 'last_name' => 'Smith')); // Prepare data for POST request $data = array('apikey' => $apiKey, 'group_id' => $group_id, 'contacts' => json_encode($contacts)); // Send the POST request with cURL $ch = curl_init('https://api.txtlocal.com/create_contacts_bulk/'); 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'; $contacts = urlencode(json_encode(array(array('number' => 447123456789, 'first_name' => 'John', 'last_name' => 'Doe'), array('number' => 447987654321, 'first_name' => 'Lucy', 'last_name' => 'Smith')))); // Prepare data for POST request $data = 'apikey=' . $apiKey . '&group_id=' . $group_id . '&contacts=' . $contacts; // Send the GET request with cURL $ch = curl_init('https://api.txtlocal.com/create_contacts_bulk/?' . $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'); $group_id = 43123; $contacts = array(array('first_name', 'last_name', 'number', 'custom1', 'custom2', 'custom3'), array('first_name', 'last_name', 'number', 'custom1', 'custom2', 'custom3')); $response = $Textlocal->createContactsBulk($numbers, $group_id); print_r($response); ?>
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" | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
contactsJSON Object |
|
||||||||||||||
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. |
Warning: It is recommended to send this request via POST, as there is a limited number of characters that can be sent via GET (approx. 8000) and a large contacts JSON object may exceed this.
[{"number":447123456789,"first_name":"John","last_name":"Doe"},{"number":447987654321,"first_name":"Lucy","last_name":"Smith"}]
{ "APIResponse":{ "success":true, "numCreated":0, "contacts":[ { "number":"447123456789", "firstName":"", "lastName":"", "custom1":"", "custom2":"", "custom3":"", "groupID":"123456", "trackingLink":"abc1/def123", "id":10000000001 },{ "number":"447987654321", "firstName":"", "lastName":"", "custom1":"", "custom2":"", "custom3":"", "groupID":"123456", "trackingLink":"abc1/def321", "id":10000000002 } ]}, "group_id":123456, "num_contacts":2, "status":"success" }
<response> <APIResponse> <success>1</success> <numCreated>2</numCreated> <contacts> <contact> <number>447123456789</number> <firstName></firstName> <lastName></lastName> <custom1></custom1> <custom2></custom2> <custom3></custom3> <groupID>123456</groupID> <trackingLink>abc1/def123</trackingLink> <id>10000000001</id> </contact> <contact> <number>447987654321</number> <firstName></firstName> <lastName></lastName> <custom1></custom1> <custom2></custom2> <custom3></custom3> <groupID>123456</groupID> <trackingLink>abc1/def321</trackingLink> <id>10000000002</id> </contact> </contacts> </APIResponse> <group_id>123456</group_id> <num_contacts>2</num_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. |
---|---|
15 | Invalid JSON string. |
25 | No group ID specified. |
33 | You have supplied too many numbers |