Get Contacts
Description
Return contacts based on optional search parameters passed in. Accepts GET or POST requests.
URL
https://melotext.com/apis/getcontacts/
Example Call: https://melotext.com/apis/getcontacts/?apikey=APIKEY&name=jimmy
PHP Code Sample (cURL):
$url = 'https://melotext.com/apis/getcontacts/';
$fields = array('apikey' => $api_key,
'name' => $name,
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
$result = curl_exec($ch);
return $result;
Parameters
Parameters | Required | Description |
---|---|---|
apikey | Required | The API key of your account. |
name | Optional | Name passed in to search on. |
Optional | Email passed in to search on. | |
number | Optional | Number passed in to search on. |
group | Optional | The group name to filter the contacts. Must pass in a valid group name that exists in the group list |
source | Optional | The signup source to filter the contacts. Valid values are 0, 1, 2, 3. 0=>import, 1=>sms, 2=>web widget, 3=>kiosk |
subscribed | Optional | Opted out / opted in contacts to filter on. Valid values are 0, 1. 0=>subscribed, 1=>unsubscribed. |
sortby | Optional | Field to sort by. Valid values are name, phone_number, created. Default is created in desc order. |
sortdir | Optional | Direction of sorting. Available values are asc, desc. Default is created in desc order. |
limit | Optional | Used to return maximum number of contacts per page. Default is 50. |
page | Optional | Page of results to retrieve. |
Return Values
Return Code | Description |
---|---|
Contacts | List of contacts returned on successful API call. |
-1 | Invalid API key passed in. |
-2 | The group passed in is invalid or does not exist. |
-3 | The source passed in is invalid. Proper values are 0, 1, 2, 3. |
-4 | The subscribed passed in is invalid. Proper values are 0, 1. |
-5 | The sortby passed in is invalid. Proper values are name, phone_number, created. |
-6 | The sortdir passed in is invalid. Proper values are asc, desc. |
-7 | No contacts found. |
-20 | Level 1 does not have access to the API. API can only be used with Levels 2, 3, and 4. |
Example API Response (data is returned in universal and lightweight JSON format)
{
"status":"0",
"contacts": [
{
"id": "23",
"name": "John Doe",
"birthday": "1974-03-23",
"email": "johndoe@gmail.com",
"number": "14154009186",
"group": "Group One",
"subscriber": "Yes",
"source": "SMS",
"carrier":"Sprint",
"date": "2017-03-12 11:02:04"
},
{
"id": "24",
"name": "John Smith",
"birthday": "1978-01-13",
"email": "",
"number": "18159819712",
"group": "Group Two",
"subscriber": "Yes",
"source": "Kiosk",
"carrier":"",
"date": "2016-12-17 13:12:04"
}
]
}