PHP code example of wenpeng / curl

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

    

wenpeng / curl example snippets


use Wenpeng\Curl\Curl;

$curl = new Curl;

$curl = Curl::init();

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

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

$curl->post(多维数组)->file($_FILE字段, 本地路径, 文件类型, 原始名称)->url(目标网址);

$curl->url(文件地址)->save(保存路径);

$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();
}