/** * Create an email campaign with the parameters provided * @param array $params associative array of parameters to create a campaign from * @return Campaign updated by server */ function createCampaign(array $params = array()) { $cc = new ConstantContact(APIKEY); $campaign = new Campaign(); $campaign->name = $params['name']; $campaign->subject = $params['subject']; $campaign->from_name = $params['from_name']; $campaign->from_email = $params['from_addr']; $campaign->greeting_string = $params['greeting_string']; $campaign->reply_to_email = $params['reply_to_addr']; $campaign->text_content = $params['text_content']; $campaign->email_content = $params['email_content']; $campaign->email_content_format = $params['format']; // add the selected list or lists to the campaign if (isset($params['lists'])) { if (count($params['lists']) > 1) { foreach ($params['lists'] as $list) { $campaign->addList($list); } } else { $campaign->addList($params['lists'][0]); } } return $cc->emailMarketingService->addCampaign(ACCESS_TOKEN, $campaign); }