Skip to content

Instantly share code, notes, and snippets.

@liamr
Created May 13, 2013 09:21
Show Gist options
  • Save liamr/5567143 to your computer and use it in GitHub Desktop.
Save liamr/5567143 to your computer and use it in GitHub Desktop.
Campaign Monitor CURL
<?php
public function signup_cm($email, $name){
$code = 'xxxx-xxxx';
// The POST URL and parameters
$request = 'http://xxxx.createsend.com/t/j/s/xxxx/?callback=my_callback';
$postargs = '';
$postargs .= 'cm-name=' . $name . '&cm-' . $code . '=' . $email;
// Get the curl session object
$session = curl_init($request);
// Set the POST options.
curl_setopt ($session, CURLOPT_POST, true);
curl_setopt ($session, CURLOPT_POSTFIELDS, $postargs);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// Do the POST and then close the session
$response = curl_exec($session);
curl_close($session);
// Get HTTP Status code from the response
$status_code = array();
// Check for errors
/*if ($status_code[0] == 199) //var_dump your status code to see what it contains - 199 is specific to my app
{
//success message
echo "This worked";
}
else
{
//fail message
echo "This does not work";
} */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment