PHP code example of brokeyourbike / php-http-client

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

    

brokeyourbike / php-http-client example snippets




// include __DIR__ . '/loader.php';
uthHeaders = [
    'Authorization: Bearer ' . $apiKey
];
$client = new BrokeYourBike\Client('https://api.sendgrid.com', $authHeaders);
$param = 'foo';
$response = $client->your()->api()->_($param)->call()->get();

var_dump(
    $response->statusCode(),
    $response->headers(),
    $response->body()
);

// include __DIR__ . '/loader.php';
uthHeaders = [
    'Authorization: Bearer ' . $apiKey
];
$client = new BrokeYourBike\Client('https://api.sendgrid.com', $authHeaders);
$queryParams = [
    'hello' => 0, 'world' => 1
];
$requestHeaders = [
    'X-Test' => 'test'
];
$data = [
    'some' => 1, 'awesome' => 2, 'data' => 3
];
$param = 'bar';
$response = $client->your()->api()->_($param)->call()->post($data, $queryParams, $requestHeaders);

var_dump(
    $response->statusCode(),
    $response->headers(),
    $response->body()
);
json
{
  "keyourbike/php-http-client": "~3.10.0"
  }
}