PHP code example of uestla / curly

1. Go to this page and download the library: Download uestla/curly 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/ */

    

uestla / curly example snippets


use Curly\Curl;

// initialize first - set temp directory for cookie files
Curl::initialize(__DIR__ . '/temp');

// GET request
$html = Curl::get($url);

// GET request with no auto-redirect
$html = Curl::get($url, FALSE);


// POST request with values
$html = Curl::post($url, [
  'foo' => 'bar',
  'hello' => 'world',
  'file' => new CURLFile($path),
]);


// HEAD request
$status = Curl::ping($url);


// last response info
$info = Curl::getInfo();

// or single info field
$httpCode = Curl::getInfo('http_code');

// all cookies across all domains
$cookies = Curl::getCookies();

// cookies for specific domain
$cookies = Curl::getCookies('http://example.com');

// cookies for specific domain and path
$cookies = Curl::getCookies('http://example.com/foo/bar');