PHP code example of alimranahmed / easyhttp

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

    

alimranahmed / easyhttp example snippets



//For GET request
$response = Http::get('www.example.com/get');
 
//For POST Request
$data = ['key' => 'value'];
$headers = ['Content-Type' => 'application/json'];
$response = Http::post('www.example.com/post', $data, $headers);
 
//For PUT request
$data = ['key' => 'value'];
$headers = ['Content-Type' => 'application/json'];
$response = Http::put('www.example.com/put', $data, $headers);
 
//For DELETE request
$response = Http::delete('www.example.com/delete');
 
//To Retrieve the response status, header and body
$response->getStatusCode(); //for status code
$response->getHeaders(); //for headers
$response->contents; //for body


Http::using('curl')->get('www.example.com/get');