【问题标题】:Aweber Integration Through Curl通过 Curl 进行 Aweber 集成
【发布时间】:2011-11-29 00:40:50
【问题描述】:

我正在尝试通过 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);

【问题讨论】:

    标签: php curl aweber


    【解决方案1】:

    在将电子邮件地址发送给 aweber 之前,您可能想尝试在电子邮件地址上使用 urlencode()...

    【讨论】:

      【解决方案2】:

      您应该在发送之前对 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');
      

      【讨论】:

        【解决方案3】:

        此代码在我使用时有效;但是,以任何其他方式发送,但直接通过表单发送将导致 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);
        

        【讨论】:

          【解决方案4】:

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

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

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2012-12-31
            • 1970-01-01
            • 1970-01-01
            • 2021-10-31
            • 1970-01-01
            • 2021-09-03
            • 1970-01-01
            • 2013-07-01
            相关资源
            最近更新 更多