簡體   English   中英

PHP File_get_contents 500 PHP中的內部服務器錯誤

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM