Created
December 18, 2012 09:01
-
-
Save rdandy/4326361 to your computer and use it in GitHub Desktop.
get facebook like count
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import urllib, simplejson as json | |
likeurl = 'http://zenphoto.rdandy.com/yaya-2012-07-14/' | |
query = 'select like_count,total_count,share_count from link_stat where url="%s"' % likeurl | |
params = urllib.urlencode({'format': 'json','query': query}) | |
url = 'https://api.facebook.com/method/fql.query?%s' % params | |
result = urllib.urlopen(url) | |
res = json.loads(result.read()) | |
""" | |
======================== | |
print res | |
[ | |
{ | |
like_count: 3, | |
total_count: 4, | |
share_count: 1 | |
} | |
] | |
res[0]['like_count'] | |
======================== | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment