PHP code example of masterklavi / phprequest

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

    

masterklavi / phprequest example snippets


use \phprequest\Request;

print Request::request('https://api.ipify.org/'); // prints your IP address received from https://api.ipify.org/
print PHP_EOL;

print Request::get('https://api.ipify.org?format=json', ['filter' => 'json'])->ip . PHP_EOL;
print Request::get('https://api.ipify.org?format=json', ['filter' => 'json_assoc'])['ip'] . PHP_EOL;

// Request::post('http://example.com', ['data' => ['name' => 'John']]);

// Request::multi(['http://example.com', 'http://example.com/1', 'http://example.com/2'], ['concurrency' => 2]);
// Request::multiPost(['http://example.com', ['http://example.com/1', ['filter' => 'json']], 'http://example.com/2'], ['concurrency' => 2]);



use \phprequest\Request;

$data = Request::get('http://www.cbr-xml-daily.ru/daily_json.js', ['filter' => 'json']);
print 'USD: ' . $data->Valute->USD->Value, PHP_EOL;


phprequest\Request;

$data = Request::get('http://www.cbr-xml-daily.ru/daily_json.js', ['filter' => 'json']);
print 'USD: ' . $data->Valute->USD->Value, PHP_EOL;

mixed Request::request(string $url, array $options = [])

mixed Request::multi(string $urls, array $options = [])

Request::get($url, ['filter' => 'json']);

Request::get($url, ['filter' => ['filter_name', $option]])

    Request::get($url, ['filter' => ['cut', $options]])
    

    Request::get($url, ['filter' => ['cut', '#reg.exp. pattern#']])