Skip to content

Instantly share code, notes, and snippets.

@colinramsay
Created June 7, 2012 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colinramsay/2888419 to your computer and use it in GitHub Desktop.
Save colinramsay/2888419 to your computer and use it in GitHub Desktop.
//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 = '9fd115edeef04b86080a2838baa28a89';
$client_id = null;
$campaign_id = null;
$list_id = '95b3a886fca5e7572963bf2c69d4ad1f';
$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($_POST["email"], $_POST["email"]);
$is_successful = $result['Result']['Code'] == 0 ? true : false;
$result_message = $result['Result']['Message'];
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
// ajax
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment