Lookup any Username on FACEBOOK

lionaneesh's Avatar author of Lookup any Username on FACEBOOK
This is an article on Lookup any Username on FACEBOOK in Python.
In this tutorial we'll be making a small yet effective application rather code snippet to Lookup Any Username on Facebook. The Code Below Uses the Graph API, The Graph API (as defined by Facebook) is the core of Facebook Platform , It allows reading and Writing access to Facebook. It provides a simple view of social graph uniformly representing objects (like people, photos, events, and pages) and the connections between them (friendships, likes, and photo tags).

To make the data handling even more simpler , Facebook returns all responses are JSON objects.

Code



To make it simple and Short I am using Python , but the same can be done in any other language!


main.py
Code:
 #!/bin/python
 import sys # for command line arguments 
 from urllib import urlopen 
 import json # for parsing 
 from StringIO import StringIO 
  
 if len(sys.argv) != 2 : # The Program Name and the Username 
     sys.exit("Usage : "+sys.argv[0]+" Username\n"); 
  
 username = sys.argv[1]; 
  
 data = urlopen("http://graph.facebook.com/"+username).read(); 
  
 io = StringIO(data); 
 user = json.load(io);   
  
 # lets parse it now! :) 
  
 print "ID\t: " , user['id'] ,"\nName\t: " , user['name'] , "\nGender\t: ", user['gender'], "\nlocale\t: " , user['locale'];
Usage :-
Code:
 Usage : main.py Username
Sample Output :-
Code:
 >>python main.py lionaneesh 


 ID    :  1203545662  
 Name    :  Aneesh Dogra  
 Gender    :  male  
 locale    :  en_US
That's all for this tutorial , Stay tuned for more!
0
lionaneesh's Avatar, Join Date: Mar 2010
Invasive contributor
Thanks for Accepting , Hoping the Readers would find it useful!
0
state's Avatar, Join Date: Sep 2011
Go4Expert Member
Kindly explain what is the logic of the program.I will try to implement the logic using JAVA.
Tank You