我的代码如下: -
$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
答案 0 :(得分:-1)
问题出在您的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);