Google URL Shortener API provide a service to short the long urls to short and vice versa. Get an API key from google to use this api by signup. Here i am giving a class to perform shorten url function. Just copy and paste the API Key in the following code & Make sure that curl is enabled in PHP. Then the script will send a curl request to google api and shorten or expand the given url.