library shrturl
a URL shortener webservice
katmore/shrturl
a URL shortener webservice
- Tuesday, March 21, 2017
- by acksponies
- Repository
- 1 Watchers
- 0 Stars
- 0 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 4 Versions
- 0 % Grown
shrturl
a URL shortener webservice, (*1)
Shrturl is a RESTful web service that behaves similar to enterprise level URL shortening services (such as bit.ly)., (*2)
-
Latest Version:, (*3)
- http://github.com/katmore/shrturl
-
Documentation, (*4)
- http://github.com/katmore/shrturl/wiki
Terminology
-
code or short code: the unique portion (token) contained in a short URL
that serves as reference to full URL. The typically jibberish looking sequence of alpha numeric
characters used in most URL shorteners.
-
short url: the full URL that includes the short code (ie: http://example.com/shrt.php?code=abc)
-
target url: the full URL that needs to be changed into a short URL
Installation
-
extract/copy the shrturl project somewhere, (*5)
git clone https://github.com/katmore/shrturl.git
cd shrturl
-
create autoloader and resolve dependencies using Composer..., (*6)
composer update
-
run the db-install.php script..., (*7)
php bin/db-install.php
-
copy app/config/shrturl/mysql-sample.ini to mysql.ini and edit..., (*8)
cp app/config/shrturl/mysql-sample.ini app/config/shrturl/mysql.ini
vi app/config/shrturl/mysql.ini
-
populate the database with initial set of randomly generated short codes..., (*9)
php bin/make-codes.php 1000
Webservice Usage
-
Redirect to target URL:, (*10)
https://example.com/shrt.php?code=abc, (*11)
(where 'abc' is the code returned by "Shorten URL" request), (*12)
-
Display short URL, Create if it does not exist, (*13)
- POST REQUEST METHOD
https://example.com/shrt.php?target=http://my_really_long_uri
- adding a query var named 'POST' to the query string to will also invoke 'POST' (if using GET REQUEST METHOD)
> https://example.com/shrt.php?POST&target=http://my_really_long_uri
-
add a query var and value for 'url_base' if you want to display a short url with a base, (*14)
URL other than what is configured in the 'default' section of shrt-config.
A value for 'url_base' should correspond with a config var in shrt-config.php, (*15)
-
POST REQUEST METHOD, (*16)
https://example.com/shrt.php?target=http://my_really_long_uri&url_base=reallyshort, (*17)
- would display/create: http://rlysh.rt/abc
- see example in shrt-config-example.php
> [https://github.com/katmore/shrturl/blob/master/shrt-config-example.php]
-
Change Target URL, (*18)
- POST REQUEST METHOD
> https://example.com/shrt.php?changeTarget=http://a_different_really_long_uri&code=abc
- adding a query var named 'POST' to the query string to will also invoke 'POST' (if using GET REQUEST METHOD)
-
Shorten Multiple URLs, (*19)
- POST REQUEST METHOD
> https://example.com/shrt.php?request={JSON_document}
- where 'target' is a valid JSON document with the following structure:
json
{"shrt":{"target":["http://target_url_1","http://target_url_2","http://etc"]}}, (*20)
- adding a query var named 'POST' to the query string to will also invoke 'POST' (if using GET REQUEST METHOD)
Webservice Deployment Suggestions
Legal
Copyright
Flat webapp - https://github.com/katmore/flat-webapp, (*27)
Copyright (c) 2012-2017 Doug Bird. All Rights Reserved., (*28)
License
"shrturl" is copyrighted free software., (*29)
You can redistribute it and/or modify it under either the terms and conditions of the
"The MIT License (MIT)"; or the terms and conditions of the "GPL v3 License"., (*30)