curlite---一款轻量级的curl组件
curlite,一款轻量级的php curl组件
Github:https://github.com/zhusaidong...
php的curl功能强大,但是原生curl参数众多,无形中增大了学习和使用的成本。curlite由此诞生。
使用
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;
参数
Response
/** * @var 响应header */ $header = []; /** * @var 响应body */ $body = ''; /** * @var http code */ $httpCode = ''; /** * @var cookie */ $cookie = ''; /** * @var 错误信息,如果curl成功,$error = FALSE */ $error = '';
Request
/** * 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
或者反馈问题,可以关注 GitHub
相关推荐
83911535 2020-11-13
曾是土木人 2020-10-31
yegen00 2020-10-21
soralaro 2020-10-11
katanaFlower 2020-09-18
wytzsjzly 2020-08-17
88407710 2020-08-17
ChinaJoeEE 2020-08-16
CyborgLin 2020-08-15
Blueberry 2020-08-15
PinkBean 2020-08-11
katanaFlower 2020-08-03
hunningtu 2020-07-30
阿债的方寸天地 2020-06-28
pingyan 2020-06-25
wytzsjzly 2020-06-25
阳光岛主 2020-06-25
阿债的方寸天地 2020-06-16