google-api

how to use Google Shortener API with Python

how to use Google Shortener API with Python Question: I want to write an app to shorten url. This is my code: import urllib, urllib2 import json def goo_shorten_url(url): post_url = ‘https://www.googleapis.com/urlshortener/v1/url’ postdata = urllib.urlencode({‘longUrl’:url}) headers = {‘Content-Type’:’application/json’} req = urllib2.Request( post_url, postdata, headers ) ret = urllib2.urlopen(req).read() return json.loads(ret)[‘id’] when I run the code …

Total answers: 3

ImportError: cannot import name SignedJwtAssertionCredentials

ImportError: cannot import name SignedJwtAssertionCredentials Question: I’m trying to access a google app through the Python Client using this code to gain authorization (private info obviously redacted): import gflags import httplib2 from apiclient.discovery import build from oauth2client.file import Storage from oauth2client.client import SignedJwtAssertionCredentials from oauth2client.tools import run f = open(‘privatekey.p12’, ‘rb’) key = f.read() f.close() …

Total answers: 8

Looking for a better python Google Calendar API example

Looking for a better python Google Calendar API example Question: I am trying to write an application that can add events to a google calendar. There is this really neat site that lets you play with the API. http://code.google.com/apis/explorer/#_s=calendar&_v=v3&_m=events.insert Using that site, I was able to build a calendar event using the following stuff. I …

Total answers: 3

Getting a cx ID for custom search, Google API – Python

Getting a cx ID for custom search, Google API – Python Question: How can I get a generic cx ID for using the custom search API in Python? http://code.google.com/p/google-api-python-client/source/browse/samples/customsearch/main.py From what I have read I understand that this cx ID is for certain sites only(when creating a custom search engine it asks me for specific …

Total answers: 4

Oauth for Google API example using Python / Django

Oauth for Google API example using Python / Django Question: I am trying to get Oauth working with the Google API using Python. I have tried different oauth libraries such as oauth, oauth2 and djanog-oauth but I cannot get it to work (including the provided examples). For debugging Oauth I use Google’s Oauth Playground and …

Total answers: 6