命令cURL到PHP cURL

时间:2016-04-14 04:59:34

标签: php curl

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

-H 'Accept: application/json'

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

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

1 个答案:

答案 0 :(得分:1)

内容类型接受是两个不同的标头。请尝试以下方法,而不是设置内容类型:

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