You are here

function CampaignMonitor::campaignCreate in Campaign Monitor 5.2

Same name and namespace in other branches
  1. 6.3 lib/CMBase.php \CampaignMonitor::campaignCreate()
  2. 6.2 lib/CMBase.php \CampaignMonitor::campaignCreate()

*

Parameters

int $client_id The ClientID you wish to use; set it to null to use the default class property.: * @param string $name (CampaignName) Name of campaign * @param string $subject (CampaignSubject) Subject of campaign mailing * @param string $fromName (FromName) The From name of the sender * @param string $fromEmail (FromEmail) The email of the sender * @param string $replyTo (ReplyTo) An alternate email to send replies to * @param string $htmlUrl (HtmlUrl) Location of HTML body of email * @param string $textUrl (TextUrl) Location of plaintext body of email * @param array $subscriberListIds (SubscriberListIDs) An array of ListIDs. This will automatically be converted to the right format * @param array $listSegments (ListSegments) An array of segment names and their corresponding ListIDs. Each element needs to * be an associative array with keys ListID and Name. * @return mixed A parsed response from the server, or null if something failed. * @see http://www.campaignmonitor.com/api/Campaign.Create.aspx

File

lib/CMBase.php, line 1289

Class

CampaignMonitor

Code

function campaignCreate($client_id, $name, $subject, $fromName, $fromEmail, $replyTo, $htmlUrl, $textUrl, $subscriberListIds, $listSegments) {
  if ($client_id == null) {
    $client_id = $this->client_id;
  }
  $_subListIds = '';
  if ($subscriberListIds != "") {
    $_subListIds = array(
      'string' => array(),
    );
    if (is_array($subscriberListIds)) {
      foreach ($subscriberListIds as $lid) {
        $_subListIds['string'] = $lid;
      }
    }
  }
  $_seg = '';
  if ($listSegments != "") {
    $_seg = array(
      'List' => array(),
    );
    if (is_array($listSegments)) {
      foreach ($listSegments as $seg) {
        $_seg['List'][] = $seg;
      }
    }
  }
  return $this
    ->makeCall('Campaign.Create', array(
    'params' => array(
      'ClientID' => $client_id,
      'CampaignName' => $name,
      'CampaignSubject' => $subject,
      'FromName' => $fromName,
      'FromEmail' => $fromEmail,
      'ReplyTo' => $replyTo,
      'HtmlUrl' => $htmlUrl,
      'TextUrl' => $textUrl,
      'SubscriberListIDs' => $_subListIds,
      'ListSegments' => $_seg,
    ),
  ));
}