Check if twitter username exists

前端 未结 9 1597
旧巷少年郎
旧巷少年郎 2021-02-05 10:28

Is there a way to check if a twitter username exists? Without being authenticated with OAuth or the twitter basic authentication?

9条回答
  •  野性不改
    2021-02-05 11:08

    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
    

提交回复
热议问题