Ejemplo n.º 1
0
 public function create_campaign()
 {
     if (!$this->session->userdata('logged_in')) {
         redirect('dashboard/login', 'location');
     }
     $campaign = Model\Campaign::find($this->input->post('location_id', TRUE));
     $campaign->campaign = $this->input->post('campaign', TRUE);
     $campaign->save();
     redirect('dashboard/main/campaigns', 'campaigns');
 }
Ejemplo n.º 2
0
 /**
  * Creates draft and automatically sends campaign
  *
  * @param array $listIDs The encrypted & hashed ids can be found under View all lists section named ID.
  * @param Model\Campaign $campaign configured campaign
  * @param string|NULL $statusMessage optional - here will be returned status message f.e. if you get FALSE again, and again, here you can find why
  * @throws \SendyPHP\Exception [\SendyPHP\Exception\CurlException|\SendyPHP\Exception\DomainException]
  * @return bool
  */
 public function sendCampaign(array $listIDs, Model\Campaign $campaign, &$statusMessage = NULL)
 {
     if (count($listIDs) == 0) {
         throw new Exception\DomainException('List IDs can not be empty');
     }
     $request = array('api_key' => $this->_getApiKey(), 'from_name' => $campaign->getSender()->getName(), 'from_email' => $campaign->getSender()->getAddress(), 'reply_to' => $campaign->getSender()->getReplyAddress(), 'subject' => $campaign->getSubject(), 'html_text' => $campaign->getEmailBody()->getHtml(), 'list_ids' => implode(',', $listIDs), 'send_campaign' => 1);
     $plainText = $campaign->getEmailBody()->getPlainText();
     if (!is_null($plainText)) {
         $request['plain_text'] = $plainText;
     }
     $response = $this->_callSendy(self::URI_CAMPAIGN, $request);
     $statusMessage = $response;
     if ($response == 'Campaign created and now sending') {
         return true;
     } else {
         return false;
     }
 }