<?php require_once '../../csrest_clients.php'; $wrap = new CS_REST_Clients('ClientID to get segments for', 'Your API Key'); $result = $wrap->get_segments(); echo "Result of /api/v3/clients/{id}/segments\n<br />"; if ($result->was_successful()) { echo "Got segments\n<br /><pre>"; var_dump($result->response); } else { echo 'Failed with code ' . $result->http_status_code . "\n<br /><pre>"; var_dump($result->response); } echo '</pre>';
function getSegments() { $filename = 'subscriber_segments.json'; $this->loadWrapperClass('csrest_clients'); $list = array(); // Check for fresh cached results if ($this->cacheNotExpired($filename) && $this->_force_flush === 'false') { $list = $this->getCached($filename); } // Uncached Results if (empty($list) || $this->_force_flush === 'true') { $list = array(); $wrap = new CS_REST_Clients($this->_client_id, $this->_api_key); $result = $wrap->get_segments(); foreach ($result->response as $item) { array_push($list, $this->objectToArray($item)); } FB::log($list); $this->setCached($filename, $list); $this->setCacheExpiry($filename); } $this->resultCount = count($list); return $list; }