curlite,一款轻量级的php curl组件php
Github:https://github.com/zhusaidong...git
php的curl功能强大,可是原生curl参数众多,无形中增大了学习和使用的成本。curlite由此诞生。github
composer require zhusaidong/curlite:dev-master
require_once './vendor/autoload.php'; use zhusaidong\CurLite\Request,zhusaidong\CurLite\Curl; $request = new Request('https://www.baidu.com/s'); $request->postFields = ['wd'=>'php curl']; $request->referer = 'https://www.baidu.com/'; $cl = new Curl($request); $response = $cl->getResponse(); echo $response->body;
/** * @var 响应header */ $header = []; /** * @var 响应body */ $body = ''; /** * @var http code */ $httpCode = ''; /** * @var cookie */ $cookie = ''; /** * @var 错误信息,若是curl成功,$error = FALSE */ $error = '';
/** * get请求 */ const METHOD_GET = 1; /** * post请求 */ const METHOD_POST = 2; /** * @var 请求url */ $url = ''; /** * @var 请求类型,默认get */ $method = self::METHOD_GET; /** * @var post数据 */ $postFields = []; /** * @var 请求header */ $header = []; /** * @var referer */ $referer = ''; /** * @var cookie */ $cookie = ''; /** * @var user-agent */ $userAgent = ''; /** * @var 请求超时时间 */ $timeout = 3;
想要深刻了解 curlite
或者反馈问题,能够关注 GitHubcookie