[Tutor] Facebook apps with python
Tony Pelletier
tony.pelletier at gmail.com
Thu Jan 19 16:24:40 CET 2012
On Wed, Jan 18, 2012 at 8:34 AM, karthik s <suryak at live.com> wrote:
> Well, my question is simple..
> How do I create facebook apps with python. I have couple of interesting/
> funky programs and want to make them as apps.
> So,
> 1. What all things I should know for writing facebook apps.
> 2. I read that we should first upload our app to 'google app engine' and
> need do link it to facebook.. Is that right?
> 3. Actually, I am not aware of Network/ Web programming.. can I be able to
> do that?
> 4. Please do mention a couple of books (ebooks) from which I can learn..
> That will help me.
I don't know if this will help, but the Facebook Graph API allows you do
neat things.
https://developers.facebook.com/docs/reference/api/
Here's something small I wrote a little while ago that just grabs all your
friends profile photos and saves them with their name as the filename. Not
necessarily anything useful, but a small example of what you can do with
it.
#!/usr/bin/env python
import os
import httplib
import json
from urllib import urlretrieve
server = 'graph.facebook.com'
myID = 'username'
accessToken = 'this is the token'
URL = "/usernam/friends?access_token=" + accessToken
def getfriends():
conn = httplib.HTTPSConnection(server)
conn.request("GET", URL)
response = conn.getresponse()
data = response.read()
list = json.loads(data)['data']
IDs = [(friends['id'], friends['name']) for friends in list]
return IDs
def getphotos():
if not os.path.exists("photos"):
os.makedirs("photos")
for id, name in getfriends():
url = "https://graph.facebook.com/" + id + "/picture"
filename = os.path.join("photos", "%s.jpg" % (name))
urlretrieve(url, filename)
def main():
getphotos()
if __name__ == '__main__':
main()
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120119/37c6d902/attachment-0001.html>
More information about the Tutor
mailing list