Twitter API GET statuses/user_timeline - 如何包括身份验证? [英] Twitter API GET statuses/user_timeline - how to include authentication?

查看:16
本文介绍了Twitter API GET statuses/user_timeline - 如何包括身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如获取请求:

https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=twitterapi&count=2

如此处所述:

https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-user_timeline.html

我有一个 oauth 用户令牌和用户令牌密钥,以及我的应用凭据...

I have an oauth user token and user token secret, plus my app credentials...

文档声明支持身份验证,但如何将其包含在无法公开访问的屏幕名称的获取请求中?

The docs state that authentication is supported, but how do I include it in the get request for screen names that are not publicly accessible?

推荐答案

如果我理解您的问题,您希望能够从第三方用户那里获取推文,其中包含 OAuth 令牌和属于某个用户的机密您的网站.来自第三方用户的推文不可公开访问,但您的用户有权访问它们.对吗?

If I understand your question right, you want to be able to get the tweets from a third-party user with the OAuth token and secrets belonging to a user on your site. The tweets from the third-party user are not publicly accessible, but your user has access rights to them. Is this right?

一般来说,如果你想代表你的用户访问私有资源,你必须使用 OAuth 令牌和您的应用程序凭据签署请求.然后 Twitter 可以检查哪个用户登录了您的网站,以及该用户是否授予了您的网站访问权限.

Generally if you want to access private ressources on behalf of your user, you have to sign the request with the OAuth token and your application credentials. Then Twitter can check, which user is signed in on your site and if the user gave your site access rights.

该签名以如下格式在您的 GET 请求的标头中发送:

That signature is sent within the header of your GET request in a format like this:

Authorization: 
        OAuth oauth_consumer_key="xvz1evFS4wEEPTGEFPHBog", 
              oauth_nonce="kYjzVBB8Y0ZFabxSWbWovY3uYSQ2pTgmZeNu2VS4cg", 
              oauth_signature="tnnArxj06cWHq44gCs1OSKk%2FjLY%3D", 
              oauth_signature_method="HMAC-SHA1", 
              oauth_timestamp="1318622958", 
              oauth_token="370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb", 
              oauth_version="1.0"

还有来自 Twitter 的文档,介绍如何计算签名.

There is also documentation from Twitter on how to calculate the signature.

这篇关于Twitter API GET statuses/user_timeline - 如何包括身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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