gpt4 book ai didi

php - Zend_Service_Twitter Oauth 签名错误

转载 作者:行者123 更新时间:2023-12-04 06:47:13 26 4
gpt4 key购买 nike

我已经成功地使用 Zend_Oauth_Consumer 连接到 twitter 并获得了一个访问 token ,但是当我尝试使用这个访问 token 时,我收到了一个错误。

这是代码:

$token = unserialize($twsession->access_token); # would be in DB
$twitter = new Zend_Service_Twitter(array(
'username' => $token->screen_name,
'accessToken' => $token
));
$response = $twitter->account->verifyCredentials();

这输出:
Zend_Rest_Client_Result Object (
[_sxml:protected] => SimpleXMLElement Object
(
[request] => /1/account/verify_credentials.xml
[error] => Incorrect signature
)

[_errstr:protected] => )

我认为代码实际上是正确的,很难说,因为 ZF 站点上的示例不完整。

FWIW 我正在使用 Zend Framework 1.10.8

最佳答案

缺少某些字段:

$token = unserialize($twsession->access_token); # would be in DB
$twitter = new Zend_Service_Twitter(array(
'username' => $token->screen_name,
'accessToken' => $token
));
$response = $twitter->account->verifyCredentials();

应该:
$token = unserialize($twsession->access_token); # would be in DB
$twitter = new Zend_Service_Twitter(array(
'username' => $token->screen_name,
'accessToken' => $token,
'consumerKey' => YOUR_APP_CONSUMER_KEY,
'consumerSecret' => YOUR_APP_CONSUMER_SECRET,
'callbackUrl' => YOUR_CALLBACK_URL
));
$response = $twitter->account->verifyCredentials();

要确认,对于有效签名,您需要与 Zend_Oauth_Consumer 一起使用的所有相同字段。

关于php - Zend_Service_Twitter Oauth 签名错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3576305/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com