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!
main.py
Usage :-
Sample Output :-
That's all for this tutorial , Stay tuned for more!
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'];
Code:
Usage : main.py Username
Code:
>>python main.py lionaneesh ID : 1203545662 Name : Aneesh Dogra Gender : male locale : en_US

