PHP code example of robsonsanches / stays-php-client

1. Go to this page and download the library: Download robsonsanches/stays-php-client 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/ */

    

robsonsanches / stays-php-client example snippets




use RobsonSanches\Stays\Client\Client;

$stays = new Client($domain, $clientId, $clientSecret, $options);

$stays->get($endpoint, $query = [], $headers = [])
$stays->post($endpoint, $data = [], $headers = [])
$stays->patch($endpoint, $data = [], $headers = [])
$stays->delete($endpoint, $query = [], $headers = [])

use RobsonSanches\Stays\Client\ClientException;

try {
    $results = $stays->get('content/groups');
    print_r( $results, true ); // array or JSON string

} catch (ClientException $e) {
    echo $e->getMessage(); // Exception message.
}

$response = $stays->http()->getResponse();

echo $response->getReasonPhrase(); // Reason phrase (string).
echo $response->getStatusCode(); // Response code (int).
echo $response->getBody()->getContents(); // Response body (JSON).

print_r( $response->getHeaders() ); // Response headers (array).
print_r( $response->getBody() ); // PSR-7 StreamInterface (object).

$request = $stays->http()->getRequest();

echo $request->getUri(); // Requested URI (string).
echo $request->getMethod(); // Request method (string).
echo $request->getBody()->getContents(); // Request body content (JSON).

print_r( $request->getHeaders() ); // Request headers (array).
print_r( $request->getUri() ); // PSR-7 UriInterface (object).
print_r( $request->getBody() ); // PSR-7 StreamInterface (object).

composer