2017-05-31 7 views
-2

イム次のスクリプト実行:この答えを与える(Mojang API)Curl 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"} 

を?

+0

は、私が働いている郵便配達や郵便配達でそれを試してみました:

コード

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain')); 

のこの行は、そのプレーンテキストが

しかし、それはこれである必要が指示します。 –

答えて

0

私は牛です。

curl_setopt($ch, CURLOPT_HTTPHEADER,  array('Content-Type: application/json')); 
関連する問題