A very lite and high compatibility but powerful curl class(especially you're processing http headers and cookies). No dependence.
$curl = new \Kenvix\curl\curl("https://bing.com/");
$curl->get(); //string response
Or:
\Kenvix\curl\curl::xget("https://bing.com/");
You can't:
echo new \Kenvix\curl\curl("https://bing.com/"); //Will always print a description
$curl = new \Kenvix\curl\curl("https://bing.com/");
$curl->post([ //something to post
'a' => 'foo',
'b' => 'excited'
]); //string response
$curl = new \Kenvix\curl\curl("https://www.bing.com/");
$curl->head(); //array response
Response:
array (size=9)
'Cache-Control' => string 'private, max-age=0' (length=18)
'Transfer-Encoding' => string 'chunked' (length=7)
'Content-Type' => string 'text/html; charset=utf-8' (length=24)
'Vary' => string 'Accept-Encoding' (length=15)
...
$curl = new \Kenvix\curl\curl("https://www.bing.com/");
$curl->head();
$curl->getCookies(); //array
Response:
Array
(
[SRCHD] => Array
(
[key] => SRCHD
[value] => AF=NOFORM
[domain] => .bing.com
[expires] => Sat, 22-Aug-2020 10:56:24 GMT
[path] => /
)
[_EDGE_V] => Array
(
[key] => _EDGE_V
[value] => 1
[path] => /
[httponly] => 1
[expires] => Mon, 16-Sep-2019 10:56:25 GMT
[domain] => bing.com
)
...
$curl = new \Kenvix\curl\curl("https://www.bing.com/",array('User-Agent: chrome', 'Referer: https://kenvix.com'));
or
$curl->setHeaders(array('User-Agent: chrome', 'Referer: https://kenvix.com'));
$curl->put($data);
$curl->delete($data);
NOTICE: CURLOPT_FOLLOWLOCATION HAS ALREADY BEEN SET TO false!!!
get() post() head() delete() put() provide a parameter to allow you to do this.
$curl->get(false);
$curl->post([...], false);
Add a cookie:
$curl->addCookie('yes=sir');
Add cookies:
$curl->addCookie([
'a' => 'foo',
'b' => 'excited'
]);
returns http code
returns
returns raw result
STATIC
parse cookies into array
STATIC
Returns curl connection
A custom request method to use instead of "GET" or "HEAD" when doing a HTTP request.