You are here

function _campaignmonitor_is_subscribed in Campaign Monitor 6

Same name and namespace in other branches
  1. 5.2 campaignmonitor.module \_campaignmonitor_is_subscribed()
  2. 5 campaignmonitor.module \_campaignmonitor_is_subscribed()
  3. 6.3 campaignmonitor.module \_campaignmonitor_is_subscribed()
  4. 6.2 campaignmonitor.module \_campaignmonitor_is_subscribed()
2 calls to _campaignmonitor_is_subscribed()
campaignmonitor_general_form in ./campaignmonitor.module
campaignmonitor_user_form in ./campaignmonitor.module

File

./campaignmonitor.module, line 379

Code

function _campaignmonitor_is_subscribed($api_key, $list_id, $email, $show_errors = false) {
  $retval = false;
  $client = _campaignmonitor_create_client();
  try {

    //make soap call
    $result = $client
      ->__soapCall("Subscribers.GetIsSubscribed", 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, "Email", "http://app.campaignmonitor.com/api/"),
      new SoapVar($name, XSD_STRING, null, null, "Name", "http://app.campaignmonitor.com/api/"),
    ), array(
      "soapaction" => "http://app.campaignmonitor.com/api/Subscribers.GetIsSubscribed",
    ));
    if ($result->Code != 0) {
      watchdog('CAMPAIGNMONITOR RESULT: ', 'Code - ' . $result->Code . ', Message - ' . $result->Message);
    }
    else {
      if ($result == 'False') {
        $retval = false;
      }
      else {
        if ($result == 'True') {
          $retval = true;
        }
      }
    }
  } 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');
    }
    $retval = false;
  }
  return $retval;
}