Thursday, March 29, 2012

python program to get facebook users data


hi guys  after 3 days of python learning i wrote my first prgram which downloads a users info (public one) using graph API its very useful API



It can be accessed like this 
Users: https://graph.facebook.com/btaylor (Bret Taylor)
Pages: https://graph.facebook.com/cocacola (Coca-Cola page)
Events: https://graph.facebook.com/251906384206 (Facebook Developer Garage Austin)
Groups: https://graph.facebook.com/195466193802264 (Facebook Developers group)
Applications: https://graph.facebook.com/2439131959 (the Graffiti app)
Status messages: https://graph.facebook.com/367501354973 (A status message from Bret)
Photos: https://graph.facebook.com/98423808305 (A photo from the Coca-Cola page)
Photo albums: https://graph.facebook.com/99394368305 (Coca-Cola's wall photos)
Profile pictures: https://graph.facebook.com/Rjcrystal.ica/picture (your profile picture)
Videos: https://graph.facebook.com/817129783203 (A Facebook tech talk on Graph API)
Notes: https://graph.facebook.com/122788341354 (Note announcing Facebook for iPhone 3.0)
Checkins: https://graph.facebook.com/414866888308 (Check-in at a pizzeria)
so just we need to put a ID after 
code
# -*- coding: utf-8 -*-
# Python
print                                             "##########################################"
print                                             "#  coded by Rjcrystal                                                 #"
print                                             "#  technomaina.blogspot.com                                     #"
print                                             "#  licensed under creative commons 2.5                      #"
print                                             "#  feedback:rjcrystal@gmail.com,                               #"
print                                             "# put group,page,profile ID                                        #"
print                                             "##########################################"

from urllib import urlopen
s = raw_input('put ID,name,etc-->')
print urlopen("http://graph.facebook.com/" + s).read()
so the problem with this is i am getting the result in 1 line only
and it adds extra' \' with every '/' but this is a great sucess for me :)
this will ask for a input just put your ID or anything to this and you will get all of its public INFO
have fun
:D

2 comments:

karim adel said...

What a nice code man. i want to develop one like this, i'd be greatfull if u can send me the code to learn it

Unknown said...

just trying... Can you get the message database from someone's account? I've tryied groups, photos and other IDs, but it didin't work with messages, just publishings

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More