我试图通过CURL集成Aweber,但它总是返回一条消息“电子邮件地址无效”,但如果我粘贴相同的url,我正在传递到浏览器地址栏中的curl,它工作,并将我添加到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);发布于 2011-11-29 08:43:23
在发送到aweber之前,您可能想尝试对您的电子邮件地址使用urlencode()。
发布于 2011-11-29 08:44:19
您应该在发送之前对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-29 09:25:18
这段代码就像我使用它一样工作;但是,以任何其他方式直接通过表单发送它将导致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);https://stackoverflow.com/questions/8304372
复制相似问题