Skip to main content
All CollectionsUsing GPlinksAdvanced Features
How to use Developers API Tool?
How to use Developers API Tool?
Anshu Bhardwaj avatar
Written by Anshu Bhardwaj
Updated over a week ago

GPlinks provide development tools for users those want to make there own system with GPlinks working environment. Lets see how it works

  1. For developers GPlinks prepared API which returns responses in JSON or TEXT formats.

  2. Currently there is one method which can be used to shorten links on behalf of your account.

  3. All you have to do is to send a GET request with your API token and URL Like the following:

Request URL Format:

https://api.gplinks.com/api?api=your-api-here&url=yourdestinationlink.com&alias=CustomAlias

4. You will get a JSON response like the following:

{"status":"success","shortenedUrl":""https:\/\/gplinks.com\/xxxxx""}

5. If you want a TEXT response just add &format=text at the end of your request as the below example. This will return just the short link. Note that if an error occurs, it will not output anything.

https://api.gplinks.com/api?api=your-api-here&url=yourdestinationlink.com&alias=CustomAlias&format=text"}

Note: API & URL are required fields and the other fields like alias, format & type are optional.

6. To use the API in your PHP application, you need to send a GET request via file_get_contents or cURL. Please check the below sample examples using file_get_contents

Using JSON Response:

$long_url = urlencode('yourdestinationlink.com'); $api_token = 'bb749cc5262a826234f61d3f387ced7418eb46da'; $api_url = "https://api.gplinks.in/api?api=<b>{$api_token}</b>&url=<b>{$long_url}</b>&alias=<b>CustomAlias</b>"; $result = @json_decode(file_get_contents($api_url),TRUE); if($result["status"] === 'error') {  echo $result["message"]; } else {  echo $result["shortenedUrl"]; }

Using Plain TEXT Response:

$long_url = urlencode('yourdestinationlink.com'); $api_token = 'bb749cc5262a826234f61d3f387ced7418eb46da'; $api_url = "https://api.gplinks.in/api?api=<b>{$api_token}</b>&url=<b>{$long_url}</b>&alias=<b>CustomAlias</b>&format=<b>text</b>"; $result = @file_get_contents($api_url); if( $result ){  echo $result; }
Did this answer your question?