1. Go to this page and download the library: Download jbzoo/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/ */
jbzoo / http-client example snippets
use JBZoo\HttpClient\HttpClient;
// Simple GET request
$client = new HttpClient();
$response = $client->request('https://api.github.com/users/octocat');
echo $response->getBody(); // JSON response
echo $response->getCode(); // 200
use JBZoo\HttpClient\HttpClient;
// Configure client (no options // Simple HTTP auth
'http-user-name',
'http-password'
],
'headers' => [ // Your custom headers
'X-Custom-Header' => 42,
],
'driver' => 'auto', // (Auto|Guzzle5|Guzzle6|Rmccue)
'timeout' => 10, // Wait in seconds
'verify' => false, // Check cert for SSL
'exceptions' => false, // Show exceptions for statuses 4xx and 5xx
'allow_redirects' => true, // Show real 3xx-header or result?
'max_redirects' => 10, // How much to redirect?
'user_agent' => "It's me", // Custom UserAgent
]);
// Just request
$response = $httpClient->request('http://my.site.com/', [
'key-1' => 'value-1',
'key-2' => 'value-2'
], 'post');