PHP HTTP request class (and traits) to provide remote request functionality (including pagination, rate limit lookups and standard 3rd-party search API methods).
Features include:
- Requests using cURL
- Requests using streams
- Recursive requests
- Rate limit access
- Multi-attempts (with sleep calls between attempts)
- Header access
- JSON parsing
POST
requests (currently limited tostream
requests)
$client = new onassar\RemoteRequests\Base();
$url = 'https://example.org';
$client->setURL($url);
$response = $client->get() ?? 'Could not load response';
echo $response;
exit(0);
$client = new onassar\RemoteRequests\Base();
$response = $client->get('https://example.org/') ?? 'Could not load response';
echo $response;
exit(0);
$client = new onassar\RemoteRequests\Base();
$client->setExpectedResponseContentType('application/json');
$url = 'https://example.org/file.json';
$client->setURL($url);
$arr = $client->get() ?? array();
print_r($arr);
exit(0);
$client = new onassar\RemoteRequests\Base();
$client->setExpectedResponseContentType('application/json');
$arr = $client->get('https://example.org/file.json') ?? array();
print_r($arr);
exit(0);
$client = new onassar\RemoteRequests\Base();
$url = 'https://example.org';
$client->setURL($url);
$param = 'value';
$requestData = compact('param');
$client->setRequestData($requestData);
$response = $client->get() ?? 'Could not load response';
echo $response;
exit(0);
$client = new onassar\RemoteRequests\Base();
$param = 'value';
$requestData = compact('param');
$client->setRequestData($requestData);
$response = $client->get('https://example.org/') ?? 'Could not load response';
echo $response;
exit(0);
$client = new onassar\RemoteRequests\Base();
$client->setRequestApproach('cURL');
$url = 'https://example.org';
$client->setURL($url);
$response = $client->get() ?? 'Could not load response';
echo $response;
exit(0);
$client = new onassar\RemoteRequests\Base();
$client->setRequestApproach('cURL');
$response = $client->get('https://example.org') ?? 'Could not load response';
echo $response;
exit(0);
- Support
POST
calls using thecURL
request approach