Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6350489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:49:10+00:00 2026-05-24T21:49:10+00:00

How to check if a username is already in use on Facebook? My solution

  • 0

How to check if a username is already in use on Facebook?

My solution was trying to access http://www.facebook.com/USER and check the http headers (200 = OK; 404 = NOT FOUND). I could use this code:

require 'open-uri'
require 'net/http'

def remote_file_exists?(url,httpcode)
  url = URI.parse(url)
  Net::HTTP.start(url.host, url.port) do |http|
    return http.head(url.request_uri).code == httpcode
  end
end

The problem is that Facebook always returns 302 (Found), then redirects to https://www.facebook.com/USER.

I can require net/https and create a new function:

def https_url_exists? (url,httpcode)
  url = URI.parse(url)
  net = Net::HTTP.new(url.host, url.port) 
  net.use_ssl = true
  net.verify_mode = OpenSSL::SSL::VERIFY_NONE
  net.start do |http|
    return (http.head(url.request_uri).code == httpcode)
  end
end

Now the problem is that some users use dots on their usernames. For example, username might be user.name. Facebook use redirections for this.

What’s the best way to check if USERNAME exists on facebook? How to get USER.NAME if USERNAME redirects to it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:49:12+00:00Added an answer on May 24, 2026 at 9:49 pm

    You can use https://graph.facebook.com/username. This will return a json response with info to see if it exists as well as enough information to identify it as a user or page.

    Once you have a valid user you can get user name First,Last info using:

    https://graph.facebook.com/{userId}?fields=first_name,last_name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to check if the username is available and display it for the
i am trying to check my user name is if its available to register
In my PHP application, I used UserName & Pwd and check the user table
Kind of an unclear question but I'm trying to check if a username has
In the following code, I am trying to check if the username entered has
Hi when I'm doing ajax call, I'm getting this in console: POST http://127.0.0.1:8000/registration/check/username/ 500
I would like to validate that a username is not already in use when
i have a signup page and i want to check username exists or not
I have a CustomValidator that is being used to check username availability, but it
How to check the username or password of the some https site is correct

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.