Retrieve Subscribers (get)
Retrieve Subscribers (get) | Get subscribers based on criteria.
<?php //example PHP code to get subscribers by criteria //set values of subscribers to get $url_params['apiKey']="APIKEY_HERE"; //Optional fields commented out below: //$url_params['sortBy']="SORTBY_HERE"; //Column to sort results by. Values: email,firstname,lastname,phone_mobile,createdate //$url_params['sortDirection']="SORTDIRECTION_HERE"; //Direction to sort results by. Values: asc or desc //$url_params['searchFields']="SEARCHFIELDS_HERE"; //Field or comma-delimited list of fields to search on. Values: email,firstname,lastname,phone_mobile //$url_params['searchValue']="SEARCHVALUE_HERE"; //Value to search for. //$url_params['start']="START_HERE"; //Control paging of subscribers, defaults to 1st page of data (page 0) //$url_params['limit']="LIMIT_HERE"; //Control paging of subscribers, number of lists to return with each call, defaults to 100 (max=100000) $url = 'http://apidomain.com/api2/subscribers'; $url = sprintf("%s?%s", $url, http_build_query($url_params)); //Uses CURL, GET Request $curl = curl_init($url); curl_setopt ($curl, CURLOPT_CONNECTTIMEOUT, 100); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec ($curl); curl_close ($curl); echo $result; //Parse the json to get return values. $parsed_result = json_decode($result,false); echo "<br><br>Status: $parsed_result->status"; echo "<br>Message: $parsed_result->message"; echo "<br>Error Code: $parsed_result->errorcode"; echo "<br>Error Message: $parsed_result->errormessage"; echo "<br># of Subscribers that match criteria: "; echo $parsed_result->data->totalrowcount; echo "<br>Subscriber ID: "; echo $parsed_result->data->data[0]->id; echo "<br>Subscriber Email: "; echo $parsed_result->data->data[0]->email; echo "<br>Subscriber ID: "; echo $parsed_result->data->data[1]->id; echo "<br>Subscriber Email: "; echo $parsed_result->data->data[1]->email; ?>