Tips for working with our API

After learning to make successful API calls through the above options, attempt to write your own code. An extension can help you troubleshoot by separating client-code bugs from network issues.

Use PHP exception handling to see actual error messages, like this:

try{
        $surl = $client->shorten($url, $data);
}catch(\Exception $e){
        print $e->getMessage();
}

Set Content-Type header for HTTP requests. So headers part would look like this:

    headers: {
        'Authorization': 'Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
        'Content-Type': 'application/json',
        'Content-Length': message.length
    }