1. Go to this page and download the library: Download osirisgate/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/ */
osirisgate / http-client example snippets
use Osirisgate\Component\HttpClient\Request\Http;
$response = Http::get('https://jsonplaceholder.typicode.com/posts');
$data = $response->toArray();
use Osirisgate\Core\Exception\ExceptionInterface;
use Osirisgate\Component\HttpClient\Request\Http;
try {
$response = Http::get('https://api.example.com/invalid');
} catch (ExceptionInterface $e) {
echo $e->getMessage(); // Not Found
echo $e->getCode(); // 404
print_r($e->format());
}
Get specific field from response
* ex: $value = $response->get('user.firstname') // return user firstname value or null if not found
* ex: $value = $response->get('user.account.balance') // return user account balance value or null if not found
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.