【问题标题】:Retrieve All User Lists using Aweber API使用 Aweber API 检索所有用户列表
【发布时间】:2016-04-02 21:16:34
【问题描述】:

我正在将 AWeber 添加为 Web 应用程序中的自动回复。使用 AWeber API,我可以将新订阅者添加到具有已知名称的列表中,在本例中为 firstlist

$app = new MyApp();
$app->findSubscriber('whtever@aol.com');
$list = $app->findList('firstlist');
$subscriber = array(
'email' => 'someemail@gmail.com',
'name'  => 'Name here'
);
$app->addSubscriber($subscriber, $list);

findList() 的函数定义为:

function findList($listName) {
    try {
        $foundLists = $this->account->lists->find(array('name' => $listName));
        return $foundLists[0];
    }
    catch(Exception $exc) {
        print $exc;
    }
}

由于我正在开发一个公共应用程序,因此我需要为用户提供一个选项来从他们的可用列表中进行选择。 请指导我如何检索所有列表名称。

【问题讨论】:

    标签: php list aweber


    【解决方案1】:

    您正在返回 $foundLists[0],因此它将返回单个列表。尝试返回 foundLists 并检查它返回的内容。 这可能会对您有所帮助:https://labs.aweber.com/snippets/lists

    【讨论】:

      【解决方案2】:

      简而言之,我通过首先找到 Aweber 用户 ID 来提取列表,以便我可以在 URL https://api.aweber.com/1.0/accounts/<id>/lists 中使用它

      为了找到用户 ID,我首先得到了帐户。

      $this->aweber->getAccount($token['access'], $token['secret']);
      

      然后,我检索用户的信息。

      $aweber_user = $this->aweber->loadFromUrl('https://api.aweber.com/1.0/accounts');
      

      由此,我用...获取了用户 ID。

      $id = $aweber_user->data['entries'][0]['id'];
      

      获得用户 ID 后,我可以使用...检索他们的列表

      $lists = $this->aweber->loadFromUrl('https://api.aweber.com/1.0/accounts/'.$id.'/lists');
      

      这个例子更多是一种程序化的方法,当然,我推荐使用类。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-04-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多