2天我在我的服务器上遇到PHP脚本问题.我什么都没改变,突然间它再也没用了.
这是代码:
$query = http_build_query($data);
$options = array(
'http' => array(
'header' => "Content-Type: application/x-www-form-urlencoded\r\n".
"Content-Length: ".strlen($query)."\r\n",
'method' => "POST",
'content' => $query,
),
);
$opts = array('http'=>array('header' => "User-Agent:MyAgent/1.0\r\n",'method' => 'POST',
'content' => http_build_query($data),));
$contexts = stream_context_create($opts);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $contexts, -1, 40000);
Run Code Online (Sandbox Code Playgroud)
我收到这些错误消息:
注意:file_get_contents():假设application/x-www-form-urlencoded in,未指定Content-type
警告:file_get_contents(https://mobile.dsbcontrol.de):无法打开流:HTTP请求失败!HTTP/1.1 500内部服务器错误
但是当我在本地尝试脚本时,它可以很好地工作.