View on GitHub

lumen-shorturl

URL Shortening Service

MaggsWeb ShortUrl API

StyleCI

A back-end URL Shortener API


Create a new ShortURL from a URL

with optional suggested short url

$client = new Client([
    'headers' => ['token' => $api_token]
]);
$response = $client->post($host.'/create', [
    'body' => json_encode([
        'long_url' => $long_url,
        'short_url' => $suggested_short_url // optional
    ])
]);
return $response->getBody()->getContents();

View ShortUrl redirect history

$client = new Client([
    'headers' => ['token' => $api_token]
]);
$response = $client->post($host.'/link', [
    'body' => json_encode([
        'short_url' => $short_url
    ])
]);
return $response->getBody()->getContents();

View User history

(optionally filtered by ShortURL)

$client = new Client([
    'headers' => ['token' => $api_token]
]);
$response = $client->post($host.'/user', [
    'body' => json_encode([                 
        'short_url' => $short_url // optional filter
    ])
]);
return $response->getBody()->getContents();

Delete Short Url

and associated activity

$client = new Client([
    'headers' => ['token' => $api_token]
]);
$response = $client->delete($host.'/link', [
    'body' => json_encode([                 
        'short_url' => $_REQUEST['short_url']
    ])
]);
return $response->getBody()->getContents();

Delete User Account

$client = new Client([
    'headers' => ['token' => $api_token]
]);
$response = $client->delete($host.'/user');
return $response->getBody()->getContents();