PHP code example of always-open / laravel-request-logger

1. Go to this page and download the library: Download always-open/laravel-request-logger 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/ */

    

always-open / laravel-request-logger example snippets


function makeFacebookApiCall(array $body, Client $facebook_client)
{
    $request_headers = [
        'api-key' => $config->apiKey,
        'Content-Type' => 'application/json',
    ];

    $versioned_path = self::buildVersionedUrlPath($path);

    $encoded_body = json_encode($body, JSON_UNESCAPED_SLASHES);

    $request = new Request(
        'GET',
        '/v1/users',
        $request_headers,
        $encoded_body,
    );
    
    $request_log = FacebookRequestLog::makeFromGuzzle($request);
    
    $response = $client->send($request);
    
    $request_log->response_code = $response->getStatusCode();
    $request_log->response = json_decode((string)$response->getBody(), true);
    $request_log->save();
}
 php
php artisan vendor:publish --provider="\AlwaysOpen\RequestLogger\RequestLoggerServiceProvider"