You are here

function _campaignmonitor_get_subscriber in Campaign Monitor 6

Same name and namespace in other branches
  1. 5.2 campaignmonitor.module \_campaignmonitor_get_subscriber()
  2. 5 campaignmonitor.module \_campaignmonitor_get_subscriber()
  3. 6.3 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 469

Code

function _campaignmonitor_get_subscriber($api_key, $list_id, $email, $show_errors = false) {
  $retval = array(
    "name" => '',
    "email" => $email,
  );
  $client = $client = _campaignmonitor_create_client();
  try {

    //make soap call
    $result = $client
      ->__soapCall("Subscribers.GetSingleSubscriber", array(
      new SoapVar($api_key, XSD_STRING, null, null, "ApiKey", "http://app.campaignmonitor.com/api/"),
      new SoapVar($list_id, XSD_INT, null, null, "ListID", "http://app.campaignmonitor.com/api/"),
      new SoapVar($email, XSD_STRING, null, null, "EmailAddress", "http://app.campaignmonitor.com/api/"),
    ), array(
      "soapaction" => "http://app.campaignmonitor.com/api/Subscribers.GetSingleSubscriber",
    ));
    if ($result->Code != 0) {
      watchdog('CAMPAIGNMONITOR RESULT: ', 'Code - ' . $result->Code . ', Message - ' . $result->Message, WATCHDOG_NOTICE);
    }
    else {
      $retval['name'] = $result->Name;
    }
  } catch (SoapFault $e) {
    if ($show_errors) {
      watchdog('ERROR IN CAMPAIGNMONITOR', 'There was an error checking if joined to newsletter: ' . $e->faultstring, WATCHDOG_ERROR);
      drupal_set_message("There is an error with the newsletter server. Please try again later.", 'error');
    }
  }
  return $retval;
}