flankerspb / curl
Simple cURL wrapper
1.0.3
2023-04-26 08:13 UTC
Requires
- php: >=7.4
- ext-curl: *
- ext-json: *
README
Simple cURL wrapper
Installation
php composer.phar require --prefer-dist flankerspb/curl
Usage
$curl = new \fl\curl\Curl([ CURLOPT_TIMEOUT => 10, CURLOPT_CONNECTTIMEOUT => 5, CURLOPT_FOLLOWLOCATION => true, CURLOPT_AUTOREFERER => true, ]); $responseGet = $curl ->setQuery([ 'key1' => 'value', 'key2' => 'value', ]) ->get('https://www.site.com/'); $responsePost = $curl ->setBody([ 'key1' => 'value', 'key2' => 'value', ], true) ->post('https://site.com/');
$curl = new \fl\curl\Curl(); $curl ->setHeader('key', 'value') ->setCookie('key', 'value') ->setProxy('socks5://user:pass@1.1.1.1:1080') ; $response = new class() implements \fl\curl\ResponseInterface { public function init($handle, array $options) : void { // TODO: Implement init() method. } }; $curl->get('https://www.site.com/', $response);