URL Shortener API \ Create a short version of an URL PHP SDK
URL Shortener API Resources
Resource/URI | GET | POST | PUT | DELETE |
---|---|---|---|---|
Shortened URLs
/shorturls.json
|
List all shortened URLs | Shorten an URL |
– | – |
Shortened URL
/shorturls/<shorturl_token>.json
|
Retrieve URL details | – | – | Delete shortened URL |
Workflow
Request: the code to send to the API
Send a POST
request with the following data to the resource /shorturls.json
to create a short version of an existing URL.
Whenever a user clicks on the short version of the url, that click will be tracked and the user will be redirected seamlessly to the original url. The click statistics can be obtained by retrieving the details of the shortened url.
POST
data to be included in the request
{ "request":{ "shorturl":{ "original_url": "#url#" } } }
Key | Description |
---|---|
* #url# |
The URL for which you want to create a short url. Example: http://www.example.org/page.html |
Result: the code returned by the API
The API will return the short version of your URL and a shorturl_token
that uniquely identifies the created entry.
{ "response": { "request": { "date": "Fri, 16 Sep 2011 16:18:49 +0200", "resource": "/shorturls.json", "status": { "flag": "success", "code": 200 } }, "result": { "data": { "shorturl": { "shorturl_token": "mOTlo", "original_url": "http://www.oneall.com/services/", "short_url": "http://oal.lu/mOTlo", "date_creation": "Fri, 16 Sep 2011 16:18:49 +0200", "num_referrals": 0 } } } } }