PHP code example of antavo / escher-php

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

    

antavo / escher-php example snippets




use Escher\Escher;

$method = 'POST';
$url = 'http://example.com';
$requestBody = '{ "this_is": "a_request_body" }';
$yourHeaders = array('Content-Type' => 'application/json');

$headersWithAuthInfo = Escher::create('example/credential/scope')
    ->signRequest('YOUR_ACCESS_KEY_ID', 'YOUR SECRET', $method, $url, $requestBody, $yourHeaders);

$client = new \GuzzleHttp\Client();
$response = $client->post($url, array(
    'body' => $requestBody,
    'headers' => $headersWithAuthInfo
));




use Escher\Escher;

$presignedUrl = Escher::create('example/credential/scope')
    ->presignUrl('YOUR_ACCESS_KEY_ID', 'YOUR SECRET', 'http://example.com');




use Escher\Escher;
use Escher\Exception;

try {
    $keyDB = new \ArrayObject(array(
        'ACCESS_KEY_OF_CLIENT_1'  => 'SECRET OF CLIENT 1',
        'ACCESS_KEY_OF_CLIENT_42' => 'SECRET OF CLIENT 42',
    ));
    Escher::create('example/credential/scope')->authenticate($keyDB);
} catch (Exception $ex) {
    echo 'The validation failed! ' . $ex->getMessage();
}