简体   繁体   English

PHP cURL-没有响应

[英]PHP cURL - getting no response

I am trying this on xampp on my local computer, but I'm getting no response from the server: 我正在本地计算机上的xampp上尝试此操作,但是服务器没有响应:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://authserver.mojang.com/authenticate");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POST, true);
$output = curl_exec($ch);
curl_close($ch);

return $output;

You are forgetting the actual POST parameters. 您忘记了实际的POST参数。

curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

Seems that the library won't send a valid request if that is not provided. 如果没有提供有效的请求,图书馆似乎不会发送该请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM