Tips for working with our API

Don't get too far ahead of yourself. Start out with something like RESTED browser extension for Google Chrome. Or Postman.

After learning to make successful API calls through the browser extension, move on and attempt writing your own code. An extension can also 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
    }