dida/curl

A lightweight PHP CURL library.

v0.2.3 2021-05-18 14:43 UTC

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);