Twitter Stream API - 401 未经授权 [英] Twitter Stream API - 401 Unauthorized

查看:43
本文介绍了Twitter Stream API - 401 未经授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法打开与 Twitter Stream API 的连接.无论我尝试什么,我都能得到的唯一响应是 401 Unauthorized.

I can't open a connection with Twitter Stream API. The only response I can get, no matter what I try, is 401 Unauthorized.

我进行了各种测试,甚至使用了我在 GitHub 上找到的一些库.

I've made all kinds of tests, even using some libraries I've found on GitHub.

即使在我的代码之外,使用 cURL,我也无法让它工作.

Even outside my code, using cURL, I can't make it work.

$oauth = array( 
    'oauth_consumer_key' => $this->m_oauth_consumer_key,
    'oauth_nonce' => time(),
    'oauth_signature_method' => 'HMAC-SHA1',
    'oauth_token' => $this->m_oauth_token,
    'oauth_timestamp' => time(),
    'oauth_version' => '1.0'
);

$base_info = $this->buildBaseString($this->url, 'GET', $oauth);
$composite_key = rawurlencode($this->m_oauth_consumer_secret) . '&' . rawurlencode($this->m_oauth_token_secret);
$oauth_signature = base64_encode(hash_hmac('sha1', $base_info, $composite_key, true));
$oauth['oauth_signature'] = $oauth_signature;
$header = $this->buildAuthorizationHeader($oauth);

这是我用于构建 HTTP 请求标头和签名的代码.我尝试了很多不同的方法,都没有成功.

This is my code for building HTTP Request Header and Signature. I've tried in a lot of different ways, no success.

没有人有什么想法可以帮助我吗?

Anoyone have any ideia that could help me?

提前致谢.

推荐答案

如果您使用的是 Linux,请将您的时间与 NTP 服务器同步:

If you're on Linux, sync your time with an NTP server:

$ sudo ntpdate ntp.org

这篇关于Twitter Stream API - 401 未经授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆