仍然无法得到打印响应卷曲在PHP

时间:2019-02-14 03:16:51

标签: php rest curl

我有使用cURL发布api的代码,我想获得curl_exec()的响应,但仍然无法获得打印响应,我该怎么办?

这是我的代码:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $host.$path);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header_curl);
// curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($curl_postData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
$response  = curl_exec($ch);
$sContentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
$resArr = json_decode($response,true);
curl_close($ch);

echo "<pre>";
print_r($response);
print_r($sContentType);
print_r($resArr);
echo "</pre>";

0 个答案:

没有答案