Php 无法打开流:权限被拒绝的文件\u获取\u生成XML文件的内容
我试图生成一个XML文件,但此PHP函数中出现错误,这是我的代码:Php 无法打开流:权限被拒绝的文件\u获取\u生成XML文件的内容,php,xml,Php,Xml,我试图生成一个XML文件,但此PHP函数中出现错误,这是我的代码: function mobile_login1($P1, $P2) { $url = 'myURL'; $data = array( 'username' => $P1, 'password' => $P2); // use key 'http' even if you send the request to https://... $options
function mobile_login1($P1, $P2)
{
$url = 'myURL';
$data = array(
'username' => $P1,
'password' => $P2);
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded",
'method' => 'POST',
'content' => http_build_query($data),
),
);
$context = stream_context_create($options);
$json_data = file_get_contents($url, false, $context);
$decode = json_decode($json_data);
//print_r ($decode[0]);
//
foreach($decode as $row)
{
$data[] = array("Message" => $row->msg);
}
//print_r ($data[0]['Message']);
$msg = $data[0]['Message'];
if ($msg == 'Incorrect username/password')
{
$this->response['ResponseCode'] = "1000";
$this->response['ResponseMessage'] = $msg;
$this->response['ResponseData'] = $data;
}
else
{
if($decode != null)
{
foreach($decode as $row)
{
$data[] = array("AccountId" => $row->a_id,
"PersonalId" => $row->p_id,
"FullName" => $row->full_name,
"AccountName" => $row->a_name,
"AccountType" => $row->a_type,
"WalletBalance" => $row->wallet_balance,
"PersonalAddress" => $row->p_add,
"CompanyName" => $row->company_name,
"CompanyAddress" => $row->company_add,
"Fax" => $row->fax,
"PersonalMobile" => $row->p_mobile,
"PersonalTelephone" => $row->p_tel,
"Limit" => $row->limit,
"Role" => $row->role,
"AccountMobile" => $row->a_telno);
}
$this->response['ResponseCode'] = "0000";
$this->response['ResponseMessage'] = "successful";
$this->response['ResponseData'] = $data;
}
else
{
$this->response['ResponseCode'] = "1000";
$this->response['ResponseMessage'] = "no records found";
}
}
//return $json_data;
}
当我试图调用我的URL时,错误是行号187
是我的文件获取内容()函数的代码
A PHP Error was encountered Severity: Warning Message:
file_get_contents(http://myURL/mobile_login): failed to open stream: Permission denied
Filename: models/accounts_model.php Line Number: 187
这是服务器故障还是PHP错误?原来是我的服务器出现问题: 我从候机楼跑了这条线来重新爱上它
setsebool -P httpd_can_network_connect on
谢谢你的建议,伙计们我在使用LAMP+Wordpress的自配置CentOS6主机上遇到了同样的问题。Wordpress函数没有返回结果(也没有返回错误),PHP文件\u get\u contents()也没有返回。在主机上执行此操作解决了问题
setsebool -P httpd_can_network_connect on
我有同样的问题,正如上面所说的,下面的问题在Centos 7上对我有效
setsebool -P httpd_can_network_connect on
您可能没有设置权限。尝试
chmod(“your/path/”,0777)
设置完整权限:chmod-R 777/filepath/在HTTP URL上设置权限有点毫无意义,伙计们…我希望我能不止一次地更新这个-我在过去的一个小时里一直在与防火墙设置抗争,却发现这只是selinux设置的一个问题,谢谢,)这对我帮助很大,帮了我很多忙。另外,我在CentOS上尝试连接到同一个盒子上的Web服务。