0
有誰知道如何從Gu HTTP HTTP客戶端提取html響應?如果你看下面的例子,我們可以很容易得到xml和json響應,但我不知道如何獲得純文本或HTML響應字符串。Gu HTTP HTTP客戶端:從響應中提取純文本或HTML
Documentation沒有純文本或HTML選項,不像json()
和xml()
。
$client = new Client($base_url);
$request = $client->createRequest($method, $uri, null, $this->requestPayload);
$response = $client->send($request);
$xml = $response->xml(); // For XML response
$json = $response->json(); // For JSON response
$html = $response->????????(); // For plain text or HTML response
對於哪個版本的Guzzle。在5中不成立。 – 2016-02-26 10:33:10
我不認爲我能記得1.5奇數年後的版本!這是一箇舊帖子。 – BentCoder 2016-02-26 11:37:07
NP,可能只是一個好主意,在答案中提到它。在Guzzle 5中,上述不起作用。相反,你必須將getBody()作爲一個字符串。 – 2016-02-26 17:08:31