PHP Code to Shorten URL Using Bitly API

Url shortening is attached with many benefits like social media friendliness and micro blogging usability, better SEO compatibility, ease of sharing, analytic data grossing, and most importantly the shortened URLs look more sober to eyes than usual orthodox long URLs.

There are many names, providing URL shortening services. Amongst all, Bitly is the most popular because of its reliability and other useful features. In this tutorial we will learn URL shortening using Bitly API

Steps to Create Shorten URL Using Bitly API

Firstly, create an account on Bitly by going to URL below:

After registering on Bitly ,you need to create an app on Bitly.

Please go to the url:

and click My Apps -> Manage My apps and then Register an application.

Now, you must have an access token to make an api call. For this click Get Registration Code .


You will receive an email on your registered email address, containing a link to take you for registering your first application.

Just fill the required details and click Create Your App button. You will be redirected to page showing client Id and client secret token for your application.

Again insert your password to generate access token.


Now use this access token in the following code to make you first call to Bitly API.

Using above php code you can easily implement Bitly API to shorten your web post url.

Leave a Comment