PHP code example of robertmain / communique

1. Go to this page and download the library: Download robertmain/communique library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

robertmain / communique example snippets



    $rest = new \Communique\Communique('http://api.company.com/');
    $response = $rest->get('users/1'); //Contains information about user number 1
    // Since $response is actually a RESTClientResponse object (rather than the raw response payload), we can get
    // properties of the request like so:
    echo $response->status; //This will be the HTTP status code
    // If we want the raw request payload we do this:
    echo $response->payload;
    // Headers can be retrieved like so:
    echo $response->getHeader('header_key');


     $rest = new \Communique\Communique('http://api.company.com/', array(new JSONParser(), new OAuth()));
     // Use the library as before


    $rest = new \Communique\Communique('http://api.company.com/', array(new JSONParser(), new OAuth()), new CustomHTTPClient());
    // Use the library as before