View on GitHub

lumen-shorturl

URL Shortening Service

MaggsWeb ShortUrl API

StyleCI

A back-end URL Shortener API


$client = new Client([
    'headers' => [
        'Authorization' => 'Basic ...',
        'Content-Type' => 'application/json'
    ]
]);

Create a new ShortURL from a URL

with optional suggested short url

$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

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

View User history

(optionally filtered by ShortURL)

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

Delete Short Url

and associated activity

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

Delete User Account

$response = $client->delete($host.'/user');
return $response->getBody()->getContents();