Skip to content
🔗 wartner.io Link-Shortener based on Laravel 5.6.21
PHP Other
  1. PHP 99.5%
  2. Other 0.5%
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
bootstrap
config
database
public
resources
routes
storage
tests
.editorconfig
.env.docker
.env.example
.gitattributes
.gitignore
.php_cs
.php_cs.cache
.phpstorm.meta.php
LICENSE
README.md
_ide_helper.php
artisan
composer.json
composer.lock
graph.png
package.json
phpunit.xml
server.php
webpack.mix.js
yarn.lock

README.md

wrtnr.li

wartner.io Link-Shortener based on Laravel 5.6.21

How to install

Clone the repository and install the composer dependencies on your server and you´re good to go.

git clone https://github.com/fwartner/wrtnr.li.git
cd wrtnr.li
cp .env.example .env
composer install
php artisan key:generate
php artisan migrate

UTM Source

wrtnr.li allows you to automatically add utm_source to the url you want to shorten.

Your URL will look like this: https://florianwartner.me/?utm_source=wrtnrli&utm_content=short_link

In order to disable this functionality, edit your .env file like this:

UTM_URL=false

How to use with PHP (Curl)

<?php

// get cURL resource
$ch = curl_init();

// set url
curl_setopt($ch, CURLOPT_URL, 'https://wrtnr.li/links');

// set method
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');

// return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// set headers
curl_setopt($ch, CURLOPT_HTTPHEADER, [
  'Content-Type: application/x-www-form-urlencoded; charset=utf-8',
]);

// form body
$body = [
  'base_url' => 'https://florianwartner.me',
];
$body = http_build_query($body);

// set body
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

// send the request and save response to $response
$response = curl_exec($ch);

// stop if fails
if (!$response) {
  die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
}

echo 'HTTP Status Code: ' . curl_getinfo($ch, CURLINFO_HTTP_CODE) . PHP_EOL;
echo 'Response Body: ' . $response . PHP_EOL;

// close curl resource to free up system resources 
curl_close($ch);

How to use with PHP (Guzzle)

<?php

// Include Guzzle. If using Composer:
// require 'vendor/autoload.php';

use GuzzleHttp\Pool;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;

$client = new Client();

$request = new Request(
        "POST",
        "https://wrtnr.li/links",
        [
            "Content-Type" => "application/x-www-form-urlencoded; charset=utf-8",
        ],
        "base_url=https://florianwartner.me");

$response = $client->send($request);
echo "Response HTTP : " . $response->getStatusCode() . "";

Responses

POST /links

Creates a new link

Request:

  • Url Params: No specific query parameters needed.

  • Body:

base_url = https://florianwartner.me

Response:

  • Status: 201

  • Body:

{
    "data": {
        "base_url": "https://florianwartner.me/",
        "new_url": "https://wrtnr.li/r/EEmgyTD",
        "redirects": 0,
        "created_at": "2018-05-14 06:09:25"
    }
}

Response:

  • Status: 409

  • Body:

{
    "error": "The Base-URL already exists"
}

GET /links

Returns a collection of all created links

Request:

  • Url Params: No specific query parameters needed.

  • Body: No specific body attributes needed.


Response:

  • Status: 200

  • Body:

{
    "data": [
        {
            "base_url": "https://florianwartner.me/",
            "new_url": "https://wrtnr.li/r/EEmgyTD",
            "redirects": 0,
            "created_at": "2018-05-14 06:09:25"
        }
    ]
}

You can’t perform that action at this time.