开发者

Twitter API - check if username exists

I just w开发者_开发技巧ant to check if a username exists in Twitter. I thought it would be part of the API, but cannot find it on the api wiki http://apiwiki.twitter.com/w/page/22554679/Twitter-API-Documentation.

Any ideas?

thanks

JP


It seems that I can pass screenname in the user search API. And I have to check for 404 not found status (if username does not exist). Seems a bit ugly, but might just work. Better suggestions welcome!

this gives 404: http://api.twitter.com/1/users/show.xml?screen_name=thisdoesnotexist1234abxfd

this returns valid info: http://api.twitter.com/1/users/show.xml?screen_name=billgates

thanks

JP

EDIT

The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.


@JP Even if the twitter api rate limit has been reached , 404 would be returned. SO this is as you said a dirty method. take into consideration the rate limit and add sufficient checks in your code so as not to reach them. the above method should work fine. regards,

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜