Y-Link
URL Shortener writen in pure PHP.
Installation
- Clone the project
$ git clone https://github.com/YehudaEi/Y-Link
-
Create Database from the dump
create_db.sql
-
Config the database in public/include/config.php in line 14
-
Config the site domain in public/include/config.php in line 16
-
Config the site url in public/YLinkClient.php in line 21
-
if you use apache go to 7. if you use nginx go to 8.
- copy apache.conf to
/etc/apache2/sites-available/
-
$ sudo mv apache.conf /etc/apache2/sites-available/servername.conf
- Config the servername.conf
- enable servername.conf
$ sudo a2ensite servername.conf
- go to 9.
-
- copy nginx.conf to
/etc/nginx/sites-available/
-
$ sudo mv nginx.conf /etc/nginx/sites-available/servername.conf
- Config the servername.conf
- enable servername
$ sudo ln -s /etc/nginx/sites-available/servername.conf /etc/nginx/sites-enabled/
- go to 9.
-
- Done! Enjoy 😁
API Docs
Methods:
- create
- Description:
Create new shorten link
- HTTP Method:
POST
- Paramaters:
- method:
- type:
string
- validLength:
4...6
- description:
the method (e.g. create, info, help...)
- type:
- password:
- type:
string
- validLength:
4...30
- description:
Creator verification
- type:
- link:
- type:
url
- description:
the long link
- type:
- method:
- Description:
- info
- Description:
Get info of shorten link
- HTTP Method:
POST
- Paramaters:
- method:
- type:
string
- validLength:
4...6
- description:
the method (e.g. create, info, help...)
- type:
- password:
- type:
string
- validLength:
4...30
- description:
Creator verification
- type:
- shorten_link:
- type:
url
- validLength:
21...47
- description:
https://y-link.ml shortened link
- type:
- method:
- Description:
- stats
- Description:
Get stats of shorten link
- HTTP Method:
POST
- Paramaters:
- method:
- type:
string
- validLength:
4...6
- description:
the method (e.g. create, info, help...)
- type:
- password:
- type:
string
- validLength:
4...30
- description:
Creator verification
- type:
- shorten_link:
- type:
url
- validLength:
21...47
- description:
https://y-link.ml shortened link
- type:
- method:
- Description:
- raw_stats
- Description:
Get raw stats of shorten link
- HTTP Method:
POST
- Paramaters:
- method:
- type:
string
- validLength:
4...6
- description:
the method (e.g. create, info, help...)
- type:
- password:
- type:
string
- validLength:
4...30
- description:
Creator verification
- type:
- shorten_link:
- type:
url
- validLength:
21...47
- description:
https://y-link.ml shortened link
- type:
- method:
- Description:
- custom
- Description:
Create new custom shorten link
- HTTP Method:
POST
- Paramaters:
- method:
- type:
string
- validLength:
4...6
- description:
the method (e.g. create, info, help...)
- type:
- password:
- type:
string
- validLength:
4...30
- description:
Creator verification
- type:
- link:
- type:
url
- description:
the long link
- type:
- path:
- type:
string
- validLength:
4...30
- description:
shortened link path: https://y-link.ml/{path}
- type:
- method:
- Description:
- edit
- Description:
Edit link destination
- HTTP Method:
POST
- Paramaters:
- method:
- type:
string
- validLength:
4...6
- description:
the method (e.g. create, info, help...)
- type:
- password:
- type:
string
- validLength:
4...30
- description:
Creator verification
- type:
- shorten_link:
- type:
url
- validLength:
21...47
- description:
https://y-link.ml shortened link
- type:
- link:
- type:
url
- description:
the long link
- type:
- method:
- Description:
- help
- Description:
Receive help
- HTTP Method:
POST
- Paramaters:
- method:
- type:
string
- validLength:
4...6
- description:
the method (e.g. create, info, help...)
- type:
- method:
- Description:
API Client
Example:
<?php
include 'YLinkClient.php';
$url = "https://yehudae.net/Home/";
$path = "custom_path";
$client = new YLink("Hello World ~ Password");
$res = $client->CreateLink($url, $path);
if ($res['ok'] == true){
echo $res['res']['link'];
}
else{
echo $res['error']['message'];
}
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.