Retrieve Lists (get)
Retrieve Lists (get) | Get lists based on criteria.
<?php //example PHP code to get lists by criteria //set values of lists to get $url_params['apiKey']="APIKEY_HERE"; $url_params['listType']="0"; //Type of lists to return. 0=All Lists, 1=SMS Lists, 2=Email & Dynamic Lists. Defaults to 0. //Optional fields commented out below: //$url_params['sortBy']="SORTBY_HERE"; //Column to sort results by. Values: listname,description,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: listname,description //$url_params['searchValue']="SEARCHVALUE_HERE"; //Value to search for. //$url_params['start']="START_HERE"; //Control paging of lists, defaults to 1st page of data (page 0) //$url_params['limit']="LIMIT_HERE"; //Control paging of lists, number of lists to return with each call, defaults to 100 (max=100000) $url = 'http://apidomain.com/api2/lists'; $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 Lists that match criteria: "; echo $parsed_result->data->totalrowcount; echo "<br>List ID: "; echo $parsed_result->data->data[0]->id; echo "<br>List Name: "; echo $parsed_result->data->data[0]->listname; echo "<br>List ID: "; echo $parsed_result->data->data[1]->id; echo "<br>List Name: "; echo $parsed_result->data->data[1]->listname; ?>