Skip to content

Instantly share code, notes, and snippets.

@rdandy
Created December 18, 2012 09:01
Show Gist options
  • Save rdandy/4326361 to your computer and use it in GitHub Desktop.
Save rdandy/4326361 to your computer and use it in GitHub Desktop.
get facebook like count
# -*- 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