Is there a way to check if a twitter username exists? Without being authenticated with OAuth or the twitter basic authentication?
Here is how it works on PHP :
$user_infos = 'http://api.twitter.com/1/users/show.xml?screen_name='.$username;
if (!@fopen($user_infos, 'r'))
{
return false;
}
return true;
This worked for me, close to what sferik has posted.
def twitter_user_exists?(user)
Twitter.user(user)
true
rescue Twitter::Error::NotFound
false
end
Using Ruby, you could install the twitter gem and then define the following method:
require 'twitter'
def user_exists?(user)
Twitter.user(user)
true
rescue Twitter::NotFound
false
end
Then, simply pass in a Twitter user name or id to your method, like so:
user_exists?("sferik") #=> true
user_exists?(7505382) #=> true