public function CampaignMonitor::getListStats in Campaign Monitor 7
Fetch stats about a given list.
This includes number of subscribers and unsubscribers. This information is temporarily stored in the local cache. The default timeout is 360 seconds.
Parameters
string $list_id: The Campaign Monitor list ID.
Return value
array|bool An array containing the stats or FALSE on failure.
File
- lib/
campaignmonitor.class.inc, line 618 - Implementation of the CampaignMonitor class.
Class
- CampaignMonitor
- Implementation of the CampaignMonitor class.
Code
public function getListStats($list_id) {
$fetch = FALSE;
if (!isset($this->listStats[$list_id])) {
// Not found inside object, try the cache.
if (($cache = cache_get('campaignmonitor_list_stats')) && !empty($cache->data)) {
// Cache information found.
$this->listStats = $cache->data;
if (!isset($this->listStats[$list_id])) {
// Not found inside cache either.
$fetch = TRUE;
}
}
else {
// No cache found or expired.
$fetch = TRUE;
}
}
if ($fetch) {
if ($obj = $this
->createListObj($list_id)) {
// Get stats from Campaign Monitor.
$result = $obj
->get_stats();
if ($result
->was_successful()) {
$this->listStats[$list_id] = (array) $result->response;
// Update the cache.
cache_set('campaignmonitor_list_stats', $this->listStats, 'cache', $this
->getCacheTimeout());
}
else {
$this
->addError(WATCHDOG_ERROR, $result->response->Message, $result->http_status_code);
return FALSE;
}
}
else {
return FALSE;
}
}
return $this->listStats[$list_id];
}