curlite---一款輕量級的curl組件

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;

參數

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 或者反饋問題,能夠關注 GitHubcookie

相關文章
相關標籤/搜索