Guzzlehttp用post方法读取API

1,638 阅读1分钟

post方式读取API数据

use GuzzleHttp\Client;
//...
$beginDate    = date('Y-m-d H:i:s', strtotime("-1 week"));
$client = new Client();
$response = $client->post(
    'uri',
    [
        'json' => [
            'start' => 0,
            'limit' => 1000,
            'conditions' => [
                'LAST_UPDATED_DATE' => [
                    'op' => 'GE',
                    'value' => $beginDate,
                ],
            ],
        ]
    ]
);
$body = $response->getBody()->getContents();
$res = json_decode($body, true);
//...