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"
}
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": {
}
}
留言