Bacalah

Learning is forever

RSS Feed

Going where this year?

Python Url Shortener using Google URL Shortener API

0 Comments
Posted by Taufiq on June 19, 2011 at 9:49 am

Udah lama maen twitter, dan baru sekarang butuh url shortener, dan ini url shortner python memanfaatkan Google URL Shortener API. enjoy

import httplib, json
 
conn = httplib.HTTPSConnection('www.googleapis.com')
conn.connect();
 
url = raw_input("masukin urlnya \n")
short = '"'+url+'"'
 
body = '{"longUrl": %s}' % short 
header = {'content-type':'application/json'}
 
conn.request('POST', '/urlshortener/v1/url', body, headers)
 
response = json.loads(conn.getresponse().read())
 
print (response["id"])
You can leave a comment, or trackback from your own site.

0 Comments

You can be the first to comment!

Leave a Reply to Anonymous Cancel reply

Your email address will not be published. Required fields are marked *