使用 1.1 - 410 Gone 获取用户关注者数量 [英] Get user follower count with 1.1 - 410 Gone

查看:22
本文介绍了使用 1.1 - 410 Gone 获取用户关注者数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个关注"按钮,其上方有一个垂直关注者计数.我有一个解决方案,直到 Twitter 今天停用 1.0 API,现在需要一个 Oauth 解决方案.我的问题是,最好、最简单的解决方案是什么(最好是 JS).

这是旧的解决方案

$.getJSON("https://api.twitter.com/1/users/show.json?callback=?&screen_name=twitter",功能(数据){$('.here').text(data);});

我现在遇到的错误

GET https://api.twitter.com/1/users/show.json?callback=jQuery20205200183007400483_1371012819892&screen_name=twitter&_=1371012819893 410 (Gone)

解决方案

首先根据 作为评论,但是是的,这是一个 简单的库我写信是为了帮助你们过渡到 twitter API 的 v1.1.

您的回复:GET https://api.twitter.com/1/[强调我自己的] 在 URL 中包含 API 版本.

最后,任何带有 /1/ 而不是 /1.1/ 的 twitter url 将不再接受任何请求,您将始终获得一个 410 (Gone) 响应.是时候升级到 1.1 了!

I'm trying to build a 'Follow' button with a vertical followers count above it. I had a solution working until Twitter retired the 1.0 API today and now require an Oauth solution. My question, what is the best, easiest solution for this (preferably JS).

Here is the old solution

$.getJSON("https://api.twitter.com/1/users/show.json?callback=?&screen_name=twitter",

function(data) { 
    $('.here').text(data);
});

And the error I'm getting now

GET https://api.twitter.com/1/users/show.json?callback=jQuery20205200183007400483_1371012819892&screen_name=twitter&_=1371012819893 410 (Gone) 

解决方案

Firstly, according to official sources:

You are discouraged from performing OAuth operations via client-side Javascript. You should perform these requests server-side. If you want the user interaction to be more client-side, the AJAX call should probably be a secure one to your own backend to initiate the tweeting process.

There isn't any easy way to perform client side requests to the new 1.1 API via AJAX. You should use some server-side language to perform this transaction, like .


You're getting 410 (Gone) response code from their API. Let's see what this actually means:

Indicates that the resource requested is no longer available and will not be available again. This should be used when a resource has been intentionally removed and the resource should be purged. Upon receiving a 410 status code, the client should not request the resource again in the future. [Emphasis my own]

Now let's take a look at the latest twitter API news:

As of yesterday, (June 11th 2013), the previously deprecated v1.0 API was retired. This means that the resource will not be available again, and you need to progress onto the v1.1 API.

The v1.1 API requires authenticated requests, usually using OAuth or 'application-specific'.

Not sure why, but you already posted the most helpful answer as a comment, but yes that's a simple library I wrote to help you guys out transitioning to v1.1 of the twitter API.

Your response: GET https://api.twitter.com/1/[Emphasis my own] contains the API version in the URL.

In closing, any twitter url's with /1/ instead of /1.1/ will no longer take on any requests whatsoever, and you will always get a 410 (Gone) response. Time to move to 1.1!

这篇关于使用 1.1 - 410 Gone 获取用户关注者数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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