dev-master
9999999-devCurl component for Palmtree PHP
MIT
The Requires
- palmtree/argparser ~1.2
- php >=5.6
by Andy Palmer
v0.9.4
0.9.4.0Curl component for Palmtree PHP
MIT
The Requires
- php >=5.6
- palmtree/argparser ~1.2
by Andy Palmer
Wallogit.com
2017 © Pedro Peláez
Curl component for Palmtree PHP
A PHP cURL wrapper to make HTTP requests easier., (*2)
Use composer to add the package to your dependencies:, (*3)
composer require palmtree/curl
You can use the static getContents method if you just want to retrieve a response body from a URL:, (*4)
<?php
use Palmtree\Curl\Curl;
$contents = Curl::getContents('https://example.org');
If you want access to the response headers and body, create a new instance instead:, (*5)
<?php
use Palmtree\Curl\Curl;
$curl = new Curl('https://example.org');
// Returns the response body when used as a string
echo $curl;
$response = $curl->getResponse();
$headers = $response->getHeaders();
$contentType = $response->getHeader('Content-Type');
$body = $response->getBody();
<?php
use Palmtree\Curl\Curl;
$curl = new Curl('https://example.org', [
CURLOPT_FOLLOWLOCATION => true,
]);
$curl->getRequest()->addHeader('Host', 'example.org');
try {
$response = $curl->execute();
} catch(CurlErrorException $e) {
}
$headers = $response->getHeaders();
$body = $response->getBody();
if($response->is404()) {
// handle 404 error
}
if($response->isOk()) {
// response status code is in the 2xx range
}
Released under the MIT license, (*6)
Curl component for Palmtree PHP
MIT
Curl component for Palmtree PHP
MIT