PHP code example of not-empty / request-service-php-lib

1. Go to this page and download the library: Download not-empty/request-service-php-lib 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/ */

    

not-empty / request-service-php-lib example snippets


use RequestService\Request;
$config = [
	'your-service' => [
		'url' => 'https://jsonplaceholder.typicode.com',
	],
];
$sample = new Request($config);
$response = $sample->sendRequest(
	'your-service',
	'GET',
	'todos/1'
);
var_dump($response);

use RequestService\Request;
$config = [
	'your-service' => [
		'url' => 'https://developer.marvel.com/',
		'json' => false,
	],
];
$sample = new Request($config);
$header = [
	'stream' => true,
];
$response = $sample->sendRequest(
	'your-service',
	'GET',
	'docs',
	$header
);
var_dump($response);
sh
php sample/request-sample.php
php sample/request-image-sample.php