1

我正在尝试通过 CURL 集成 Aweber,但它总是返回一条消息“电子邮件地址无效”,但如果我将传递给 curl 的相同 url 粘贴到浏览器地址栏中,它可以工作并将我添加到 aweber 列表中。任何人都可以指导我如何通过 curl 使其工作这是我的代码:

$listname = 'sarnia-basic'; // YOUR LIST NAME
$adtracking = 'sarniabusiness'; // AD TRACKING

$url = 'http://www.aweber.com/scripts/addlead.pl?listname=sarnia-basic&meta_adtracking=sarniabusiness&name=Mohammad Tanveer&email=tanveer_411393@hotmail.com&meta_message=1&redirect=http://www.aweber.com/form/thankyou_vo.html';              

$ch1 = curl_init( $url );               

$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 );                

$mh = curl_multi_init();

curl_multi_add_handle($mh, $ch1);               

$running = null;

do {
curl_multi_exec($mh, $running);
} while ($running);

$html = curl_multi_getcontent($ch1);                

curl_multi_remove_handle($mh, $ch1);

curl_multi_close($mh);
4

4 回答 4

0

如果您通过 curl 请求添加电子邮件,Aweber 将阻止您的 IP 地址。

他们有一个 API,可让您添加订阅者:https ://labs.aweber.com/

于 2015-04-22T20:58:31.017 回答
0

您可能想尝试在您的电子邮件地址上使用 urlencode(),然后再将其发送给 aweber...

于 2011-11-29T00:43:22.747 回答
0

您应该在发送之前对 url 参数进行编码。电子邮件字段中的“@”字符应编码为“%40”。当然正确的方法是使用-> http://php.net/manual/en/function.urlencode.php

编辑:

$url = 'http://www.aweber.com/scripts/addlead.pl?listname='.urlencode('sarnia-basic').'&meta_adtracking='.urlencode('sarniabusiness').'&name='.urlencode('Mohammad Tanveer').'&email='.urlencode('tanveer_411393@hotmail.com').'&meta_message='.urlencode('1').'&redirect='.urlencode('http://www.aweber.com/form/thankyou_vo.html');
于 2011-11-29T00:44:19.380 回答
0

此代码在我使用时有效;但是,以任何其他方式发送,但直接通过表单发送将导致 a)电子邮件地址的所有者收到确认,以及 b)从您的服务器 IP 地址而不是他们自己的 IP 地址添加订阅者,这可能会让您在而如果它违反了 aweber 的 TOS。如果您需要在提交之前将订阅者添加到数据库或进行其他处理,最好的方法是通过 ajax 进行所有处理,一旦处理完成返回 true,表单将提交。

<?php

$strPost = ''; 

foreach($_POST as $key => $val) 
{ 
    $strPost .= $key . '=' . urlencode(trim($val)) . '&'; 
} 

$strPost = substr($strPost, 0, -1);  

$strUrl = 'http://www.aweber.com/scripts/addlead.pl';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $strUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,array('Expect:');               
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_NOBODY, FALSE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $strPost);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
$response = curl_exec($ch);
curl_close($ch);
于 2011-11-29T01:25:17.670 回答