Below is a sample response. Note that response are returned in json format. This means that you will need the decode that use the native decoding of the language you use in your application. If there are no errors encountered during the process, the "error" element will be set to 0, otherwise to 1. You can use this to validate the content before using it.GET https://pwgo.to/api/?url=http://www.google.com&api=APIKEY
{"error":"0","short":https://pwgo.to/mnQRi"}
$content=@file_get_contents("https://pwgo.to/api/?url=http://www.google.com&api=APIKEY");$url=json_decode($content,TRUE);//Decodes json into an arrayif(!$url["error"]){ // If there is no errorecho $url["short"]; //Outputs the short url}else{echo $url["msg"]; //Outputs the error message}
If there is a problem, the error element will be set to "0" and an error message will be set. There are several error messages. For example, if the API key is not set or is invalid, an error message will tell you that.
These are some cases you can expect an error:
{
"error":"1","msg":"Service have been disabled."}