dida / curl
A lightweight PHP CURL library.
This package's canonical repository appears to be gone and the package has been frozen as a result. Email us for help if needed.
    v0.2.3
    2021-05-18 14:43 UTC
Requires
- php: ^5.5 || ^7.0
 
This package is not auto-updated.
Last update: 2021-11-30 17:51:56 UTC
README
Usage
常规用法
use \Dida\Curl\Client;
$client = new Client("http://localhost:8123", "POST");
$response = $client
            ->addQuery('ts', time())
            ->addPost('user', 'Tom')
            ->addPost('age', '25')
            ->addPostArray([
                  'foo' => 1234,
                  'bar' => 'abcd',
            ])
            ->request();
echo var_export($response, true);
以 JSON 模式提交
use \Dida\Curl\Client;
$client = new Client("http://localhost:8123", "POST");
$response = $client
            ->addQuery('ts', time())
            ->addPost('user', 'Tom')
            ->addPost('age', '25')
            ->setJsonMode()  // <--设置为json模式
            ->request();
echo var_export($response, true);