Skip to content

Instantly share code, notes, and snippets.

@kristjan
Created April 11, 2011 22:43
Show Gist options
  • Save kristjan/914533 to your computer and use it in GitHub Desktop.
Save kristjan/914533 to your computer and use it in GitHub Desktop.
Convert a Facebook username to its ID
#!/usr/bin/env ruby
require 'net/http'
require 'rubygems'
require 'json'
username = ARGV.first
if username.nil?
puts "Usage: #{__FILE__} <fb_username>"
end
info = Net::HTTP.get 'graph.facebook.com', "/#{username}?fields=id"
puts JSON.parse(info)['id']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment