blob: 74d408d926d0e6a46873b4b8685943ba93677c1e [file] [log] [blame]
Joe Gregorio652898b2011-05-02 21:07:43 -04001# version: v1
2# title: Command-line sample for the Google URL Shortener API.
3# scope: https://www.googleapis.com/auth/urlshortener
4# description: Simple command-line example for Google URL Shortener API that shortens a URI then expands it.
5
6 url = service.url()
7
8 # Create a shortened URL by inserting the URL into the url collection.
9 body = {"longUrl": "http://code.google.com/apis/urlshortener/" }
10 resp = url.insert(body=body).execute()
11 pprint.pprint(resp)
12
13 short_url = resp['id']
14
15 # Convert the shortened URL back into a long URL
16 resp = url.get(shortUrl=short_url).execute()
17 pprint.pprint(resp)