开发者

URL to get my Twitter followers says "requires authentication" even though I am logged in

开发者 https://www.devze.com 2023-02-23 00:08 出处:网络
I want to get the user_id fie开发者_Go百科lds of my Twitter followers. Seems like this API method is what I am looking for:

I want to get the user_id fie开发者_Go百科lds of my Twitter followers.

Seems like this API method is what I am looking for:

http://api.twitter.com/1/statuses/followers/NicolasRaoul.xml

Unfortunately it returns an XML file that says This method requires authentication.

Even though this method is documented as Requires Authentication: False

Furthermore, I am logged into Twitter as NicolasRaoul (typing URL in the same browser).

What am I doing wrong?


The Twitter screen name NicolasRaoul does not exist as of this writing, so that could be part of your problem.

When I clicked the link you provided, I received the same error message you did, however shortly thereafter, I tried again and received what I expected to receive:

<?xml version="1.0" encoding="UTF-8" ?> 
<hash>
    <request>/1/statuses/followers/NicolasRaoul.xml</request> 
    <error>Not found</error> 
</hash>

I don't know why I initially received the request to authenticate; I should have received a 404. For what it's worth I can say, after all my years of working with the Twitter API, that Twitter can be pretty flaky every once in awhile, so let's just hope your error was due to Twitter having a bad day.

Since NicolasRaoul doesn't exist, I'll use Nicolas_Raoul (hopefully you) for the following examples.

For your use case, I would suggest utilizing http://api.twitter.com/1/followers/ids/Nicolas_Raoul.xml to get up to 5,000 follower user IDs. If you have more than 5,000 followers, you'll need to make use of the cursor parameter. Documentation is here.

Alternatively, you could use http://api.twitter.com/1/statuses/followers/Nicolas_Raoul.xml to get the full user objects of 100 of your followers returned in the order that they followed you. If you have more than 100 followers, you'll need to again use the cursor parameter. Documentation is here.

Note that for all Twitter API calls, I recommend using JSON since it is a much more lightweight document format than XML. You will typically transfer only about 1/3 to 1/2 as much data over the wire, and I find that (in my experience) Twitter times-out less often when serving JSON.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号