dongzhong7443 2015-03-30 23:33
浏览 23

Aweber与PHP集成

I am trying to add members to Aweber list when they sign up on my website but I get an error.

I was wondering if anyone could help me with that.

I get: AWeberAPIException: Type: NotFoundError Msg : Object: None, name: '' Docs: https://labs.aweber.com/docs/troubleshooting#notfound

I am pretty sure it's $list = $account->loadFromUrl($listURL); below. Would you please tell me what I am doing wrong?

Thanks guys

<?php error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once('aweber_api/aweber_api.php');
$consumerKey = '**********';
$consumerSecret = '**********';
$accessKey      = '***'; # put your credentials here
$accessSecret   = '***'; # put your credentials here
$account_id     = '***'; # put the Account ID here
$list_id        = 'awlist5252553'; # put the List ID here
$aweber = new AWeberAPI($consumerKey, $consumerSecret);
# Get an access token
if (empty($_COOKIE['accessToken']))
    {
        if (empty($_GET['oauth_token'])) 
            {
                $callbackUrl = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
                list($requestToken, $requestTokenSecret) = $aweber->getRequestToken($callbackUrl);
                setcookie('requestTokenSecret', $requestTokenSecret);
                setcookie('callbackUrl', $callbackUrl);
                header("Location: {$aweber->getAuthorizeUrl()}");
                exit();
            }
        $aweber->user->tokenSecret = $_COOKIE['requestTokenSecret'];
        $aweber->user->requestToken = $_GET['oauth_token'];
        $aweber->user->verifier = $_GET['oauth_verifier'];
        list($accessToken, $accessTokenSecret) = $aweber->getAccessToken();
        setcookie('accessToken', $accessToken);
        setcookie('accessTokenSecret', $accessTokenSecret);
        header('Location: '.$_COOKIE['callbackUrl']);
        exit();
}
# Get AWeber Account
try {
        $account = $aweber->getAccount($_COOKIE['accessToken'], $_COOKIE['accessTokenSecret']);
        $listURL = "/accounts/".$account_id."/lists/".$list_id;
        $list = $account->loadFromUrl($listURL);
        # create a subscriber
        $params = array(
            'email' => $_POST['email']
        );
        $subscribers = $list->subscribers;
        $new_subscriber = $subscribers->create($params);
        # success!
        print "A new subscriber was added to the $list->name list!";

    }
catch(AWeberAPIException $exc) 
    {
        print "<h3>AWeberAPIException:</h3>";
        print " <li> Type: $exc->type              <br>";
        print " <li> Msg : $exc->message           <br>";
        print " <li> Docs: $exc->documentation_url <br>";
        print "<hr>";
        exit(1);
    }?>

</div>
  • 写回答

2条回答 默认 最新

  • dongzhang8475 2015-04-02 10:52
    关注

    replace following lines

    $listURL = "/accounts/".$account_id."/lists/".$list_id;
        $list = $account->loadFromUrl($listURL);
    

    with following lines

    $lists = $account->lists->find(array('name' => $listName));
    $list = $lists[0];
    

    $listName here refers to name of list, not list id

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大