Skip to content

Instantly share code, notes, and snippets.

@imvision
Last active December 25, 2015 06:39
Show Gist options
  • Save imvision/6933888 to your computer and use it in GitHub Desktop.
Save imvision/6933888 to your computer and use it in GitHub Desktop.
Add a lead to aweber list using PHP & curl
<?php
// Encode them for URL
$email = urlencode( utf8_encode( $email ) );
$fullname = urlencode( utf8_encode( $fullname ) );
//
// 3. Define Aweber Variables
//
$listname = 'users-premium'; // IMPORTANT: change to your list name!
$adtracking = 'wp-ipn'; // tracking variable (optional)
//
// 4. Build URL
//
$url = 'http://www.aweber.com/scripts/addlead.pl?listname=' . $listname . '&meta_adtracking=' . $adtracking . '&name=' . $fullname . '&email=' . $email . '&meta_message=1';
//
// 5. Run the URL via CURL
//
// build the individual requests as above, but do not execute them
$ch1 = curl_init( $url );
// Options: http://se2.php.net/manual/en/function.curl-setopt.php
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERAGENT => 'Mozilla/5.0',
CURLOPT_HEADER => false,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_TIMEOUT => 10,
CURLOPT_FAILONERROR => true,
CURLOPT_AUTOREFERER => true,
);
curl_setopt_array( $ch1, $options );
// build the multi-curl handle, adding both $ch
$mh = curl_multi_init();
curl_multi_add_handle($mh, $ch1);
// execute all queries simultaneously, and continue when all are complete
$running = null;
do {
curl_multi_exec($mh, $running);
} while ($running);
// all of our requests are done, we can now access the results
//$html = curl_multi_getcontent($ch1);
// close
curl_multi_remove_handle($mh, $ch1);
curl_multi_close($mh);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment