You are here

function _campaignmonitor_get_subscriber in Campaign Monitor 5.2

Same name and namespace in other branches
  1. 5 campaignmonitor.module \_campaignmonitor_get_subscriber()
  2. 6.3 campaignmonitor.module \_campaignmonitor_get_subscriber()
  3. 6 campaignmonitor.module \_campaignmonitor_get_subscriber()
  4. 6.2 campaignmonitor.module \_campaignmonitor_get_subscriber()
1 call to _campaignmonitor_get_subscriber()
campaignmonitor_general_form in ./campaignmonitor.module

File

./campaignmonitor.module, line 434

Code

function _campaignmonitor_get_subscriber($api_key, $list_id, $email, $show_errors = FALSE) {
  $retval = array(
    "name" => '',
    "email" => $email,
  );
  $cm = new CampaignMonitor($api_key, $client_id, $campaign_id, $list_id);
  $result = $cm
    ->makeCall('Subscribers.GetSingleSubscriber', array(
    'params' => array(
      'ListID' => $list_id,
      'EmailAddress' => $email,
    ),
  ));
  if ($result['anyType']['Code'] != 0) {
    watchdog('campaignmonitor', 'Code - ' . $result['anyType']['Code'] . ', Message - ' . $result['anyType']['Message'], WATCHDOG_ERROR);
    if ($show_errors) {
      drupal_set_message("There is an error with the newsletter server. Please try again later.", 'error');
    }
  }
  else {
    $retval['name'] = $result['anyType']['Name'];
  }
  return $retval;
}