更新时间:2021-10-24 05:49:17
你可以使用这个 javascript 库:codebird-js 带有仅应用程序身份验证".
You can use this javascript library: codebird-js with the "Application-only auth".
或
自己动手:文档中解释了所有内容>.
基本上你需要遵循 3 个步骤(你应该先做 2 个步骤一次):
Basically you need to follow 3 steps (and you should do the 2 first just once):
文档中详细介绍了这些步骤.
The steps are detailed in the documentation.
您可以单独执行前 2 步,当您获得不记名令牌时,您需要在每个请求中添加特定的 HTTP 标头(授权)以及您的不记名令牌(这是第 3 步).使用 jQuery,它可能是这样的:
You can do the first 2 separately and when you get your bearer token, you need to add a specific HTTP Header (Authorization) in each request with your bearer token (that's the 3rd step). With jQuery it could be something like that:
$.ajax({
headers: { Authorization: 'Bearer '+$my_bearer_token },
url: 'https://api.twitter.com/1.1/search/tweets.json?q='+$search
}).done(function (data) {
// Play with the data
});