google-api

How to a shorten a URL using the goo.gl API?


I want API code to shotern url to goo.gl. I want to develop program in visual basic with module. I already made an application of tiny url it works fine but now I want it for goo.gl


Solution

  • Here's the documentation

    POST a json object to https://www.googleapis.com/urlshortener/v1/url

    POST https://www.googleapis.com/urlshortener/v1/url
    Content-Type: application/json
    
    {"longUrl": "http://www.google.com/"}
    

    The response is also JSON.

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

    curl example:

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