You can use the Google Shortener API .
Using REST, you can send the JSON value as follows:
{"longUrl": "http://stackoverflow.com/"}
and the result will look like this:
{ "kind": "urlshortener#url", "id": "http://goo.gl/lgNaMv", "longUrl": "http://stackoverflow.com/" }
You need to implement authentication. Regards.
source share