Beispiel #1
0
         // ERROR SENDING
     } else {
         /*echo json_encode(array(
         			"status" => "error",
         			"type" => $result["name"]
         		));*/
         echo json_encode(array("status" => "error", "type" => "Looks like something went wrong. Please try again later."));
         errorlog("mailchimp", $result["name"]);
     }
 } elseif ($STORE_MODE == "campaignmonitor") {
     $api_key = $CM_API_KEY;
     $list_id = $CM_LIST_ID;
     /*$client_id = null;
     		$campaign_id = null;*/
     $cm = new CampaignMonitor($api_key, null, null, $list_id);
     $result = $cm->subscriberAdd($email, $firstname);
     // SUCCESS SENDING
     if ($result['Result']['Code'] == 0) {
         echo json_encode(array("status" => "success"));
         // ERROR SENDING
     } else {
         /*echo json_encode(array(
         			"status" => "error",
         			"type" => $result['Result']['Message']
         		));*/
         echo json_encode(array("status" => "error", "type" => "Looks like something went wrong. Please try again later."));
         errorlog("campaignmonitor", "Error : " . $result['Result']['Code'] . " : " . $result['Result']['Message']);
     }
 } elseif ($STORE_MODE == "getresponse") {
     $gr = new GetResponse($GR_API_KEY);
     $campaign = $gr->getCampaignByName($GR_CAMPAIGN_NAME);
<?php 
//Sample using the CMBase.php wrapper to call Subscriber.AddWithCustomFields from any version of PHP
//Relative path to CMBase.php. This example assumes the file is in the same folder
require_once 'CMBase.php';
//Your API Key. Go to http://www.campaignmonitor.com/api/required/ to see where to find this and other required keys
$api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$client_id = null;
$campaign_id = null;
$list_id = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$cm = new CampaignMonitor($api_key, $client_id, $campaign_id, $list_id);
//Optional statement to include debugging information in the result
//$cm->debug_level = 1;
//This is the actual call to the method, passing email address, name.
$result = $cm->subscriberAdd('*****@*****.**', 'Joe Smith');
if ($result['Result']['Code'] == 0) {
    echo 'Success';
} else {
    echo 'Error : ' . $result['Result']['Message'];
}
//Print out the debugging info
//print_r($cm);
Beispiel #3
0
 private function form_handler($page_name, $newsletter)
 {
     $view = new View('public_newsletter/newsletters/form');
     $view->page_name = $page_name;
     $values = array('name' => '', 'email' => '');
     $view->values = $values;
     if ($_POST) {
         $post = new Validation($_POST);
         $post->pre_filter('trim');
         $post->add_rules('name', 'required');
         $post->add_rules('email', 'required', 'valid::email');
         if (!$post->validate()) {
             $view->errors = arr::overwrite($values, $post->errors('form_error_messages'));
             $view->values = arr::overwrite($values, $post->as_array());
             return $view;
         }
         include Kohana::find_file('vendor', 'CMBase');
         $cm = new CampaignMonitor(null, null, $newsletter->cm_list_id);
         $result = $cm->subscriberAdd($_POST['email'], $_POST['name']);
         if ($result['Result']['Code'] != 0) {
             kohana::log('error', $result['Result']['Message']);
             return 'There was an error adding you to the emailing list. Please try again later.';
         }
         return 'Thank you! You have been adding to our mailing list.';
     }
     return $view;
 }