You are here

function cc::query_campaigns in Constant Contact 7.3

Same name and namespace in other branches
  1. 6.3 class.cc.php \cc::query_campaigns()
  2. 6.2 class.cc.php \cc::query_campaigns()

Queries the API for campaigns with a certain status.

Supported status codes are: SENT All campaigns that have been sent and not currently scheduled for resend SCHEDULED All campaigns that are currently scheduled to be sent some time in the future DRAFT All campaigns that have not yet been scheduled for delivery RUNNING All campaigns that are currently being processed and delivered

@access public

File

./class.cc.php, line 1414
Constant Contact PHP Class

Class

cc
@file Constant Contact PHP Class

Code

function query_campaigns($status = 'SENT') {
  $xml = $this
    ->load_url('campaigns?status=' . urlencode($status));
  if (!$xml) {
    return FALSE;
  }

  // Parse into nicer array.
  $campaigns = array();
  $_campaigns = isset($xml['feed']['entry']) ? $xml['feed']['entry'] : FALSE;
  if (is_array($_campaigns)) {
    if (isset($_campaigns[0]['link_attr']['href'])) {
      foreach ($_campaigns as $k => $v) {
        $id = $this
          ->get_id_from_link($v['link_attr']['href']);
        $campaign = $v['content']['Campaign'];
        $campaign['id'] = $id;
        $campaigns[] = $campaign;
      }
    }
    else {
      $id = $this
        ->get_id_from_link($_campaigns['link_attr']['href']);
      $campaign = $_campaigns['content']['Campaign'];
      $campaign['id'] = $id;
      $campaigns[] = $campaign;
    }
  }
  return $campaigns;
}