1. Go to this page and download the library: Download hxgf/http-request 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/ */
hxgf / http-request example snippets
use VPHP\http;
$api_data = http::request('https://external-api.com/v3/example-response', [
'method' => 'POST', // optional, GET by default, GET and POST supported currently
'json_decode' => true, // optional, returns an expected JSON response as a PHP array
'debug' => true, // optional, returns all request information from curl_getinfo()
'headers' => [ // optional, define any custom header
'Cache-Control' => 'no-cache',
'Content-Type' => 'application/json',
],
'data' => [ // optional, will be submitted as querystring (GET) or FormData (POST)
'user_id' => 581146,
'api_key' => '696719xvckvzxspigh24y1e-b'
]
]);