API สำหรับนักพัฒนา

This page shows the uses and instructions for the full spectrum of our API. Some are simple 'User' http:// functions, while other go deeper into advanced coding for the 'Developer'. Please take a good read, there are some awesome functions we have added over time to make the User and Developer happy. 

Please Contact Us if you have any requests for further additions in the future...

 

Registering for an API Key

As before, an API key is required for requests to be processed by the system. Once a user registers, an API key is automatically generated for this user. The API key must be  attached to the request via the api parameter. (see full example below)

Sending a request for shortening a URL

To send a request, the user must use the following format where the variables api and url are required. To request a custom alias, simply add &custom= at the end.

GET http://14ty.me/api?key=APIKEY&url=THELONGURLTOBESHORTENED&custom=CUSTOMALIAS

 

More advanced Developer & coding requirements needed for the following API functions...

Server response

As before, the response will be encoded in the JSON format (default). This is done to facilitate cross-language usage. The first element of the response will always tell if an error has occurred (error: 1) or not (error: 0). The second element will change with respect to the first element. If there is an error, the second element will be named “msg”. which contains the source of error, otherwise it will be named “short” which contains the short URL. (See below for an example)

// No errors
{
  "error":0,
  "short":"http:\/\/14ty.me\/BFT1o"
}
// An error has occurred
{
  "error":1,
  "msg":"Please enter a valid URL"
}

 USING PLAIN TEXT FORMAT

You can now request the response to be in plain text by just adding &format=text at the end of your request. This will return just http://14ty.me/BFT1o instead of the JSON response. Note that if an error occurs, it will not output error messages or anything at all.

 

Using the API in PHP

To use the API in your PHP application, you have to send a GET request through file_get_contents or cURL: Both are reliable methods. You can see a sample code below using file_get_contents.

<?php
  // Using JSON Response
  $api_url="http://yoursite.com/api?key=APIKEY&url=THELONGURLTOBESHORTENED&custom=CUSTOMALIAS";
  $res= @json_decode(file_get_contents($api_url),TRUE);
  if($res["error"]){
    echo $res["msg"];
  }else{
    echo $res["short"];
  }

  // Using Plain Text Response
  $api_url="http://yoursite.com/api?api=APIKEY&url=THELONGURLTOBESHORTENED&custom=CUSTOMALIAS&format=text";
  $res= @file_get_contents($api_url);
  if($res){
    echo $res;
  }
?>

 

If you have any further idea's for our API, please use the Contact Us page. We are happy to use Volunteer Coders as we are swamped with our Community-Based Open Development Collaborative work (which this website does belong).  So we are very very grateful for any help coders & designers can lend. Of course you'll be added to this websites & our Community Project website pages for 'Contributors' with Name / Link / Social Media info and work accomplished on both sites with shout outs across our Network of Social Media accounts. All Contributor's on 14TY.me receive a Lifetime Premium Membership and the Designer Treasure Chest ($49) + a Developer/Designer Package ($1250+) from one of our Sponsors MightyDeals.com + many more premium perks from our other Web Services (Plus the addition to your Portfolio will speak for itself as 14TY.me is part of the 1st Community-Based Project Collaborative Co-Founded by Forrst.me V.I.P Invitee's, so from experience the work follows from others and our own many contacts).

P.S: API Dedicated with Thanks to ALL the Volunteers, Contributors, Donators and Sponsors for helping us keep our Contributors/Volunteers in awesome 'Schwag' & Free Perks/Bonuses!