flexyproject / curl
1.1.3
2016-08-20 23:53 UTC
Requires
- php: >=7
- ext-curl: *
README
这是一个PHP7面向对象的cURL扩展包装器。
安装
composer require flexyproject/curl
使用方法
require 'vendor/autoload.php'; use \FlexyProject\Curl\Client; // Create Client object $curl = new Client(); // Set Url $curl->setUrl('https://api.github.com/user'); // Set options (here authentication options) $curl->setOption([ CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_USERPWD => sprintf('%s:%s', 'user', 'pass') ]); // Success callback $curl->success(function (Client $instance) { $instance->getHeaders(); // Get headers info $instance->getResponse(); // Get response body }); // Error callback $curl->error(function (Client $instance) { $instance->getHeaders(); // Get headers info $instance->getResponse(); // Get response body }); // Perform request $curl->perform();