Today we will learn how to use Bitly URL Shortener in our Apps. For this tutorial we are going to use Bitly API.
One thing to note is that Bitly is going to discontinue their API V3 in 2020 and that is why in today’s tutorial we will use Bitly API V4.
So the first thing you need is to create a Free Bitly Account which you can create on Bitly.com Remember guys that you can sign up using Google but I will not recommend that because we will need the Bitly account Password in the next step. So create an account using Email ID and Password.
Now that you have created your account, the next step is to get an Access Token for Bitly API. To get one go to the website https://bitly.is/accesstoken Here you have to enter your Password (This is why I told you to create account using Email ID and Password).
Here you will get your Access Token. Copy and Paste this access token to a safe place such as your notes. Now you need a GUID for the access token. You can generate the GUID using an app created by me called Bitly API V4 GUID. Install the Android App from the link given at the end and just paste the access token in the Access Token Field. GUID will be generated.
Now Copy the GUID and paste it in the notes.
Now we will build the App.
First in the Designer I have used one Textbox Component for long URL. Next I used a button for shortening the link and a label that will display the Shortened URL. And the last but not the least I inserted a Web Component which will serve as the backbone of our app.
Now comes the Blocks Section.
(You can skip these and just upload the provided .aia file)
Firstly I have created a procedure that will send an request to the Bitly Servers for a Short URL. In this we will use the Access Token, GUID and Long URL as input. First it will set the URL of the Web Component as provided by Bitly Documents. Next the request headers of the Web Component are set as provided by Bitly Documents and the last the Web Component will send the Long URL along with the GUID to Bitly Servers.
You can use this Procedure in any of your app by just downloading the .aia file to your dashboard and copying the block to the Backpack
Next we will trigger this procedure when the button is clicked by the user.
As a result the Short URL will be sent by Bitly Servers to the App which we set to the Label Text after decoding as the Response Content is in JSON Format.
Now we are done.
The download links of the mentioned Apps and .aia file are given below.
Download Bitly GUID App:- https://bit.ly/32WacPe
Download Bitly_URL_Shortener.aia File:- http://bit.ly/2JbPXEz
Download Bitly URL Shortener App:- http://bit.ly/2JjaIhY