-2
Im做下面的脚本:(Mojang提供API)卷曲PHP错误,如何解决?
curl_setopt($ch, CURLOPT_URL, "https://authserver.mojang.com/authenticate");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$headers = array(
'Accept: application/json','Content-Type=application/json'
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{
"agent": {
"name": "Minecraft",
"version": 1
},
"username": "idk",
"password": "something",
"requestUser": true
}');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain'));
$result=curl_exec ($ch);
echo $result;
它给予这样的回答:
{"error":"Unsupported Media Type","errorMessage":"The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method"}
如何解决不支持的媒体类型的错误?
我跟邮递员,邮递员试了一下工作。 –