Aweber授权码不起作用

时间:2012-09-06 16:53:31

标签: php api aweber

这是一个奇怪的问题:当我授权我的Aweber应用程序时,授权代码第一次运行。

然而,当我刷新页面时,我收到一个错误:     AWeberAPIException:

Type: UnauthorizedError 
Msg : RequestToken key is invalid.     https://labs.aweber.com/docs/troubleshooting#unauthorized 

文档:https://labs.aweber.com/docs/troubleshooting#unauthorized

请帮助这真令人沮丧。这是我正在使用的代码:

require_once('aweber_api/aweber_api.php');

try {
# set $authorization_code to the code that is given to you from
# https://auth.aweber.com/1.0/oauth/authorize_app/YOUR_APP_ID
    $authorization_code="Azh...";

$auth = AWeberAPI::getDataFromAweberID($authorization_code);
list($consumerKey, $consumerSecret, $accessKey, $accessSecret) = $auth;

# Store the Consumer key/secret, as well as the AccessToken key/secret
# in your app, these are the credentials you need to access the API.
//$account = $aweber->getAccount($accessKey, $accessSecret);

}
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>";
}

1 个答案:

答案 0 :(得分:4)

好的,我解决了!

授权令牌包含$consumerKey$consumetSecret$accessKey$accessSecret

以下行返回Array

$auth = AWeberAPI::getDataFromAweberID($authorization_code);

所以,

$consumerKey = $auth[0];
$consumerSecret = $auth[1];
$accessKey = $auth[2];
$accessSecret = $auth[3];

然后您只需使用这些值来授权应用程序!当然,如果它被多个用户使用,则需要为每个用户存储这些值。