[英]PHP file_get_contents 500 Internal Server error in php
我的代码如下:
$context = stream_context_create(array('http' => array(
'method' => "POST",
'header' => "Content-Type:text/xml\r\nUser-Agent:PHPRPC/1.1\r\n",
'content' => $request )));
$file = file_get_contents($this->server, false, $context);
Warning:
file_get_contents(http://abc.co.in/employers/index.php/JobPostingServices/getResponse):
failed to open stream: HTTP request failed! HTTP/1.0 500 Internal Server Error in /var/www/project/client.php on line 40
问题出在您的User-Agent标头中。 这为我工作:
$opts = array('http'=>array('header' => "User-Agent:MyAgent/1.0\r\n"));
$context = stream_context_create($opts);
$header = file_get_contents('https://www.example.com',false,$context);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.