6

我正在为 TwitPic 使用meltice 的 API,当我尝试上传图片时,我收到 401 错误消息“无法对您进行身份验证(标题被 twitter 拒绝)”。

我的标头(从 HTTP Request2 对象中检索)是:

Array
(
    [user-agent] => HTTP_Request2/2.0.0 (http://pear.php.net/package/http_request2) PHP/5.2.17
    [x-verify-credentials-authorization] => OAuth realm="http://api.twitter.com/", oauth_consumer_key="****************", oauth_signature_method="HMAC-SHA1", oauth_token="#########-******************", oauth_timestamp="1325192643", oauth_nonce="***********", oauth_version="1.0", oauth_signature="****************%3D"
    [x-auth-service-provider] => https://api.twitter.com/1/account/verify_credentials.json
    [content-type] => multipart/form-data
)

我确保 verify_credentials 签名正在使用 GET,并且我看不到任何其他问题。

我究竟做错了什么?

谢谢 :)

编辑:这是我的源代码。

$venue = $this->Venue->findById($venueId);
$twitterData = json_decode($venue['Venue']['twitter_data']);
$token = $twitterData->token;
$secret = $twitterData->secret;
$this->Twitter->loginTwitterUser($token, $secret);
require_once(WWW_ROOT.'twitpic/TwitPic.php');

$twitpic = new TwitPic('**********', '*******', '*********', $token, $secret);


$result['result'] = $twitpic->upload(array('media'=> '/home/todays/public_html/tsm/app/webroot/files/uploads/LOGOA7V1_10.png', 'message'=> 'test'));

而且我确信令牌、秘密和应用程序凭据是正确的,因为它们在我的 Twitter API 中工作时没有任何问题。我还仔细检查了 Twitpic API 密钥。

4

1 回答 1

2

检查 TwitPic文档后,我注意到解释了 401 错误:This method will return a 401 Unauthorized if the OAuth header was not present or could not be verified with Twitter.

你是说你确保verify_credentials签名使用 GET 而 API 只接受 POST。也许那是你的问题?

以下是与您正在使用的 API 相关的示例代码:

于 2012-01-06T20:53:20.073 回答