Go4Expert (http://www.go4expert.com/)
-   Python (http://www.go4expert.com/articles/python-tutorials/)
-   -   Lookup any Username on FACEBOOK (http://www.go4expert.com/articles/lookup-username-facebook-t27093/)

lionaneesh 5Nov2011 16:50

Lookup any Username on FACEBOOK
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.


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


 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 :-

Usage : main.py Username
Sample Output :-

>>python main.py lionaneesh

 ID    :  1203545662 
 Name    :  Aneesh Dogra 
 Gender    :  male 
 locale    :  en_US

That's all for this tutorial , Stay tuned for more! :)

lionaneesh 6Nov2011 10:16

Re: Lookup any Username on FACEBOOK
Thanks for Accepting , Hoping the Readers would find it useful! :)

state 3Jan2012 10:00

Re: Lookup any Username on FACEBOOK
Kindly explain what is the logic of the program.I will try to implement the logic using JAVA.
Tank You

All times are GMT +5.5. The time now is 03:38.