PHP code example of flashytime / curl

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

    

flashytime / curl example snippets


$curl = new \Flashytime\Curl\Curl();

$curl = \Flashytime\Curl\Curl::init();

$curl->url($url)->get();

//$params is a query parameter array, like ['id' => 1, 'uid' => 2]
$curl->url($url, $params)->get();

//$data is a multi array
$curl->url($url)->set($data)->post();

$curl->url($url)->set($data)->put();

$curl->url($url)->set($data)->patch();

$curl->url($url)->delete();

$curl->url($url)->download($file);

//$option is the CURLOPT_XXX option
$curl->setOption($option, $value)
->url($url)
->set($data)
->post();

$curl->setOptions([$option1 => $value1, $option2 => $value2])
->url($url)
->set($data)
->post();

if ($curl->error()) {
    var_dump($curl->message());
}
//the response data
$response = $curl->response();
$curl->close();