This command can be used to retrieve all contacts within a group.
https://api.textlocal.in/get_contacts/
<?php
// Account details
$apiKey = urlencode('Your apiKey');
// Group details
$group_id = '123456';
// Prepare data for POST request
$data = array('apikey' => $apiKey, 'group_id' => $group_id);
// Send the POST request with cURL
$ch = curl_init('https://api.textlocal.in/get_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');
// Group details
$group_id = '123456';
// Prepare data for POST request
$data = 'apikey=' . $apiKey . '&group_id=' . $group_id;
// Send the GET request with cURL
$ch = curl_init('https://api.textlocal.in/get_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');
$group_id = '123456';
$limit = 1000;
$start = 0;
$response = $Textlocal->getContacts($group_id, $limit, $start);
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" and group 6 contains "opt-outs". |
|---|---|
| number | A specific number that you want to retrieve from the specified group. Using this parameter will also return a Link Tracking parameter for sending out pre-created surveys via the API. |
| 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. |
{
"group_id":123456,
"start":0,
"limit":1000,
"num_contacts":2,
"contacts":[{
"number":"918123456789",
"first_name":"John",
"last_name":"Doe",
"custom1":"Male",
"custom2":"",
"custom3":"",
"linkTracking":"abc1/def123"
},
{
"number":"918987654321",
"first_name":"Lucy",
"last_name":"Smith",
"custom1":"Female",
"custom2":"",
"custom3":"",
"linkTracking":"abc1/def123"
}],
"status":"success"
}<?xml version="1.0" encoding="UTF-8" ?> <response> <group_id>123456</group_id> <start>0</start> <limit>1000</limit> <num_contacts>2</num_contacts> <contacts> <contact> <number>918123456789</number> <first_name>John</first_name> <last_name>Doe</last_name> <custom1>Male</custom1> <custom2></custom2> <custom3></custom3> </contact> <contact> <number>918987654321</number> <first_name>Lucy</first_name> <last_name>Smith</last_name> <custom1>Female</custom1> <custom2></custom2> <custom3></custom3> </contact> </contacts> <status>success</status> </response>
| Error Codes | |
| 10 | Invalid group ID. |
|---|---|
| 25 | No group ID specified. |