-
-
Save yahelc/57028738e649c15c3b15 to your computer and use it in GitHub Desktop.
Getting +1 counts in Python using GAE urlfetch
This file contains 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
from google.appengine.api import urlfetch | |
totals = {} | |
result = urlfetch.fetch(url="https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ", payload=form_fields, method=urlfetch.POST, headers={'Content-Type': 'application/json'}) | |
plusone = json.loads(result.content) | |
try: | |
totals["GooglePlusOne"] = int(plusone[0][u"result"][u"metadata"][u"globalCounts"][u"count"]) | |
except KeyError: | |
totals["GooglePlusOne"] = 0 | |
except ValueError: | |
totals["GooglePlusOne"] = 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment