PHP code example of dcarbone / curl-plus

1. Go to this page and download the library: Download dcarbone/curl-plus library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dcarbone / curl-plus example snippets


use DCarbone\CurlPlus\CURL;

$response = CURL::get('http://www.gstatic.com/hostedimg/6ce955e0e2197bb6_large');

$image = imagecreatefromstring((string)$response);

header('Content-Type: image/jpeg');
imagepng($image);
imagedestroy($image);

use DCarbone\CurlPlus\CURL;

$client = new CurlPlusClient(
    'http://my-url.etc/api',
    array(
        CURLOPT_RETURNTRANSFER => true,
    ));


// Returns \DCarbone\CurlPlus\CurlPlusResponse object
$response = $client->execute();

echo $response->responseBody."\n";
var_dump($response->responseHeaders);
var_dump($response->error);

// Set the URL you wish to query against, additionally you may also reset any existing curl opts
public function initialize($url, $reset = true) {}

// Accepts any options seen here: http://www.php.net//manual/en/function.curl-setopt.php
public function setCurlOpt($opt, $val) {}

// Accepts an associative array of Curl Opts
public function setCurlOpts(array $array) {}