public function CampaignMonitorCampaign::createCampaign in Campaign Monitor 8
Create a new campaign at the Campaign Monitor servers. The side-effect is that the local cache is cleared.
Parameters
array $data: Has the following keys: 'Subject' => 'Campaign Subject', 'Name' => 'Campaign Name', 'FromName' => 'Campaign From Name', 'FromEmail' => 'Campaign From Email Address', 'ReplyTo' => 'Campaign Reply To Email Address', 'HtmlUrl' => 'Campaign HTML Import URL', # 'TextUrl' => 'Optional campaign text import URL', 'ListIDs' => array('First List', 'Second List'), 'SegmentIDs' => array('First Segment', 'Second Segment')
Return value
bool TRUE on success, FALSE otherwise.
File
- modules/
campaignmonitor_campaign/ src/ CampaignMonitorCampaign.php, line 63
Class
Namespace
Drupal\campaignmonitor_campaignCode
public function createCampaign($data) {
if ($obj = $this
->createCampaignObj(NULL)) {
$result = $obj
->create($this->campaignMonitor->client_id, $data);
if ($result
->was_successful()) {
// Clear the cache, so the list information can be retrieved again.
$this->campaignMonitor
->clearCache();
return $result
->was_successful();
}
else {
$this->campaignMonitor
->addError(WATCHDOG_ERROR, $result->response->Message, $result->http_status_code);
drupal_set_message(t('Error message: @message', [
'@message' => $result->response->Message,
]));
return FALSE;
}
}
return FALSE;
}