Command cURL to PHP cURL


Command cURL to PHP cURL

我正在尝试将命令cURL的这一部分转换为PHP cURL:

-H 'Accept: application/json'

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); 

但是添加它会导致CURLOPT_POSTFIELDS无法发布。

内容类型接受是两个不同的标头。与其设置内容类型,不如尝试以下操作:

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));