Bacalah

Learning is forever

RSS Feed

Going where this year?

Python Url Shortener using Google URL Shortener API

2 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.

2 Comments

  • On September 14, 2011 at 6:31 am rahmanu said

    iku isa dilebokke dabr ra Pik?

    Reply

  • On September 19, 2011 at 4:07 pm topx666 said

    iso banget nu 😀

    Reply

Leave a Reply

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