PHP code example of birjemin / curl

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

    

birjemin / curl example snippets


$curl = new Curl;

$curl = Curl::init();

$curl->url(目标网址);

$curl->post(变量名, 变量值)->post(多维数组)->url(目标网址);

$curl->put(变量名, 变量值)->put(多维数组)->url(目标网址);

$curl->delete(变量名, 变量值)->delete(多维数组)->url(目标网址);

$curl->set('CURLOPT_选项', 值)->post(多维数组)->url(目标网址);

// 出错自动重试N次(默认0)
$curl->retry(3)->post(多维数组)->url(目标网址);

// 任务结果状态
if ($curl->error()) {
    echo $curl->message();
} else {
    // 任务进程信息
    $info = $curl->info();
    
    // 任务结果内容
    $content = $curl->data();
}