PHP code example of fabricekabongo / simplehttpclient

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

    

fabricekabongo / simplehttpclient example snippets


$client = new FabriceKabongo\Http\HttpClient();
$responseData = $client->get('http://www.google.com');

$client = new FabriceKabongo\Http\HttpClient();
$responseData = $client->get('http://www.google.com', array('q' => 'tallest falls in africa');//http://www.google.com?q=tallest%20falls%20in%20africa

$client = new FabriceKabongo\Http\HttpClient();
$responseData = $client->post('http://www.myawesomeapi.com', array('foo' => 'bar');

$client = new FabriceKabongo\Http\HttpClient();
try {
    $responseData = $client->base64Upload('http://www.myawesomeapi.com', __DIR__."/myfile.txt");
} catch (\Exception $ex) {
    //log oups
}
bash
touch myfile.txt && echo "random content" > myfile.txt