$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'somesite.com');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: application/json',
'Content-Length: ' . strlen($body)
));
返回响应 HTTP / 1.1 401 Unauthorized Content-Type:text / html;
但是我将内容类型设置为application / json,如上所示。为什么呢?