从Twitter v1.1开始,如何通过简单的浏览器条目将twitter搜索结果作为json获取? [英] How to get twitter search results as json with simple browser entry since Twitter v1.1?

查看:94
本文介绍了从Twitter v1.1开始,如何通过简单的浏览器条目将twitter搜索结果作为json获取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究tuts + jQuery课程,并且被困在一个课程上,该课程旨在让学生从Twitter搜索中检索json对象.该课程建议用户尝试以下搜索(在我的浏览器地址栏中):

I'm working on the tuts+ jQuery course and am stuck on a lesson where the student is meant to retrieve json objects from a Twitter search. The lesson advises the user to try the following search (in my browser address bar):

http://search.twitter.com/search.json?q=tutspremium

此URL的错误是{"errors": [{"message": "The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.", "code": 68}]}.我已经解决了这个问题,并找到了以下搜索内容:

The error for this url is {"errors": [{"message": "The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.", "code": 68}]}. I've worked that problem and found the following search:

https://api.twitter.com/1.1/search/tweets.json?q=tuts%20premium

我认为这是正确的字符串,但是出现身份验证错误.进一步的阅读告诉我,我需要新的Twitter API上所有端点上的授权.

I think this is the right string, but I get an auth error. Further reading tells me I need authorization on all endpoints on the new Twitter API.

如何设置将推文获取为json的授权?如果我不想成为Twitter会员怎么办?我可以只对应用程序进行身份验证并在我的搜索功能中建立信誉吗?即:

How do I set up authorization for getting tweets as json? What if I don't want to be a member of Twitter? Can I do Application only auth and build the creds in to my search function? i.e.:

function getTweets( search ) {
    return $.ajax({
        url: 'https://api.twitter.com/1.1/search/tweets.json, 
        data: { q: search },
        dataType: 'jsonp',
        authCredentials
    });
});

理想情况下,我只想要最简单的解决方案,这样我就可以继续学习本课程所学的内容.谢谢.

Ideally I just want the simplest solution so I can go on learning deffereds from this course. Thanks.

推荐答案

首先,您必须在此处注册应用并获取消费者密钥和消费者秘密.然后,您将需要验证您的请求(请参阅文档).

First you have to register your app here and get the consumer key and consumer secret. Then you will need to authenticate your request (see the documentation).

这篇关于从Twitter v1.1开始,如何通过简单的浏览器条目将twitter搜索结果作为json获取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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