Google url shortener

Google提供了goo.gl這個服務, 可以將網址縮短

http://www.google.com/ -> http://goo.gl/fbsS

程式的用法是

縮網址
$ curl https://www.googleapis.com/urlshortener/v1/url -H 'Content-Type: application/json' -d '{"longUrl": "http://www.google.com/"}'

{
 "kind": "urlshortener#url",
 "id": "http://goo.gl/fbsS",
 "longUrl": "http://www.google.com/"
}

恢復短網址
$ curl 'https://www.googleapis.com/urlshortener/v1/url?shortUrl=http://goo.gl/fbsS'

{
 "kind": "urlshortener#url",
 "id": "http://goo.gl/fbsS",
 "longUrl": "http://www.google.com/",
 "status": "OK"
}

看統計資料
$ curl 'https://www.googleapis.com/urlshortener/v1/url?shortUrl=http://goo.gl/fbsS&projection=FULL'
{
 "kind": "urlshortener#url",
 "id": "http://goo.gl/fbsS",
 "longUrl": "http://www.google.com/",
 "status": "OK",
 "created": "2009-12-13T07:22:55.000+00:00",
 "analytics": {
  "allTime": {
   "shortUrlClicks": "13779",
   "longUrlClicks": "368710",
   "referrers": [
   "countries": [
   "browsers": [
   "platforms": [
  "month": {
  "week": {
  "day": {
  "twoHours": {
 }
}

留言

這個網誌中的熱門文章

買車記

怎麼在兩台linux server間用scp而不需打密碼?

Costco退貨真爽快