Google URL Shortener For developers

Google URL Shortener For developers

14.Sep.2021

How to create a short link using Google URL Shortener API

Step 1: Go to the Google APIs Console and create a new project. In this article, I will be creating an app named "URLShorten" . After the project is created, enable billing for your app. You will have to click on "Select a project" drop down menu next to "Google Cloud Platform" logo in the upper left corner of the screen and select your newly created project from there.

Note: Enable Billing for App Engine Project

Step 2: Create a file named Procfile at the root directory of your app with following contents [APP_ENGINE_API_NAME = [YOUR_PROJECT_]] [hostname] [and] [PORT = 8080]

hostname = appengine.google.com

app engine opens the framework for web development. The framework is based on python language or java programming language with some restrictions imposed by app engine which will be discussed later in this article. In your Procfile, you need to edit the second line as per your application name and port number of your choice.

Step 3: Create a file named appengine-web.xml at the root directory of your app with following contents

In this file, you have configure handler for URL shortening service and specify that it should use HTTPS protocol and save all requests into a compressed format (gzip) . You also need to mention that this service must run on a particular port.

 

Step 4: Create a file named appengine-web.xml at the root directory of your app with following contents

In this file, you have configure handler for URL shortening service and specify that it should use HTTPS protocol and save all requests into a compressed format (gzip). You also need to mention that this service must run on a particular port.

Step 5: Now we create files which will be used by webapp2 framework in python language to handle requests from users according to their platform Android/ios/web/desktop etc . For android platform , we create an xml file named mobile_android.xml in our root directory with following contents

ForOS device , we create an xml file named mobile_web.xml in our root directory with following contents

For web Browser , we create a html file named index.html at the root directory of your app with following contents

In this file, you have provided values for GoogleMap Api key and email address. You can get these from your Google Cloud project under APIs & auth section as shown below

You also need to download googleapi python module from https://pypi.python.org/pypi/googleapi and place it inside src folder . You may also download Android SDK from http://developer.android.com/sdk/index.html and extract it in android folder . All other necessary files will be created during re-deployment of your app .

Note: Continue to work on Python 2.7 for this version.

Step 6: Now we create files which will be used by webapp2 framework in python language to handle requests from users according to their platform Android/ios/web/desktop etc. For android platform, we create an xml file named mobile_android.xml in our root directory with following contents

ForOS device, we create an xml file named mobile_web.xml in our root directory with following contents

For web browser, we create a html file named index.html at the root directory of your app with following contents

In this file, you have provided values forMap Api key and email address. You can get these from your Google Cloud project under APIs & auth section as shown below

You also need to download googleapi python module from https://pypi.python.org/pypi/googleapi and place it inside src folder . You may also download Android SDK from http://developer.android.com/sdk/index.html and extract it in android folder . All other necessary files will be created during re-deployment of your app.

Note: Continue to work on Python 2.7 for this version.

Step 7: Now we create files which will be used by webapp2 framework in python language to handle requests from users according to their platform Android/ios/web/desktop etc. For android platform, we create an xml file named mobile_android.xml in our root directory with following contents

ForOS device, we create an xml file named mobile_web.xml in our root directory with following contents

For web browser, we create a html file named index.html at the root directory of your app with following contents

In this file, you have provided values forMap Api key and email address. You can get these from your Google Cloud project under APIs & auth section as shown below

 

We are social