//PHP CODE
//Install guzzleHttp at first, Document: https://docs.guzzlephp.org/
//php composer.phar require guzzlehttp/guzzle:~6.0
use GuzzleHttp\Client;
try{
$client = new \GuzzleHttp\Client();
$res = $client->request('POST', "https://m5.gs/shortener-api", [
'form_params' => [
"url" => "https://www.YOUR-URL.com/",
"token" => "YOUR TOKEN"
]
]);
$json_array = json_decode($res->getBody(), true);
if($json_array['code'] == 0){
$short_url= $json_array['shorturl'];
echo $short_url;
}else{
echo "Error:".$json_array['message'];
}
}catch(Exception $e){
//do somethings...
}
//Return json data
array = [
"code" => xxx,
"shorturl" => "xxx",
"message" => "xxx"
];
//Return status code
code status:
0 - Success code , Return short url
1 - Error code , There was a problem with the original long URL provided,or maliciou URL
2 - Error code , Request speed is too fast, resulting in rate limit
3 - Error code , Any other error(Problems with our service such as a maintenance period)
4 - Error code , Token error