function _campaignmonitor_get_lists in Campaign Monitor 6.3
Get all lists from campaign monitor identified by client ID and API key.
Parameters
string $api_key:
string $client_id:
Return value
array off lists.
1 call to _campaignmonitor_get_lists()
- campaignmonitor_admin_settings_form in includes/
campaignmonitor.admin.inc - Menu callback that creates the administartion settings form.
File
- ./
campaignmonitor.module, line 726 - Module that plugs in Campaign Monitor functionality to your Drupal web site. For Campaign Monitor information see: http://www.campaignmonitor.com/
Code
function _campaignmonitor_get_lists($api_key, $client_id, $reset = FALSE) {
static $data;
if (!isset($data) || $reset) {
if (!$reset && ($cache = cache_get('campaignmonitor_lists')) && !empty($cache->data)) {
// Cache information found.
$data = $cache->data;
}
else {
$data = array();
// Get lists from campaign monitor.
$cm = new CampaignMonitor($api_key, $client_id, $campaign_id, $list_id);
$result = $cm
->clientGetLists();
if (empty($result) || $result['anyType']['Code'] != 0) {
if (empty($result)) {
watchdog('campaignmonitor', 'There was a problem with the connection to Campaign Monitor.');
}
else {
watchdog('campaignmonitor', 'Get Lists: Code - %code, Message - %message', array(
'%code' => $result['anyType']['Code'],
'%message' => $result['anyType']['Message'],
));
}
drupal_set_message(CM_ERROR, 'error', FALSE);
}
else {
if (!empty($result['anyType']['List'])) {
$lists = $result['anyType']['List'];
// If there is only one list.
if (!empty($lists['ListID'])) {
$data[$lists['ListID']] = $lists['Name'];
}
else {
foreach ($lists as $list) {
$data[$list['ListID']] = $list['Name'];
}
}
}
}
// Save the lists in the cache.
cache_set('campaignmonitor_lists', $data);
}
}
return $data;
}