【发布时间】:2019-03-03 04:36:35
【问题描述】:
我正在使用 guzzle 获取单个页面的帖子,它工作正常。但现在的问题是页面在每页上有分页 20 个帖子。我想得到所有的帖子。如何使用 guzzle 做到这一点?
这是我的代码:
public function __construct()
{
$this->client = new Client([
'base_uri' => 'https://xxxxxx.com/',
'Content-Type' => 'application/json',
]);
}
public function post($post)
{
$response = $this->client->request('GET', $post);
$output = $response->getBody()->getContents();
$data = $this->getData($output);
return $data;
}
【问题讨论】: