PHP code example of swimtobird / kong-hmac

1. Go to this page and download the library: Download swimtobird/kong-hmac 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/ */

    

swimtobird / kong-hmac example snippets



        $hamc = new Hmac('user','secret','example.com','GET');

        $hamc->setUrl('/default');

        $header = $hamc->getHeader();


        $client = new GuzzleHttp\Client(['base_uri' => 'http://example.com']);

        $request = $client->request('GET', '/default', [
            'headers' => $header
        ]);

        print json($response->getBody(),true);


        $hamc = new Hmac('user','secret','example.com','POST');

        $hamc->setUrl('/default');

        $header = $hamc->getHeader();


        $client = new GuzzleHttp\Client(['base_uri' => 'http://example.com']);

        $request = $client->request('POST', '/default', [
            'headers' => $header
            'form_params'=>[
                'params' => 'test'
            ]            
        ]);

        print json($response->getBody(),true);