Created
May 13, 2013 09:21
-
-
Save liamr/5567143 to your computer and use it in GitHub Desktop.
Campaign Monitor CURL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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