Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 文件“获取”内容在端口8282上不起作用_Php_Post_File Get Contents - Fatal编程技术网

Php 文件“获取”内容在端口8282上不起作用

Php 文件“获取”内容在端口8282上不起作用,php,post,file-get-contents,Php,Post,File Get Contents,我得到了下面的基本脚本,它提出了一个基本的POST请求(我只想让它工作,在我添加更多内容之后): 结果告诉我: Warning: file_get_contents(http://******:8282/api/incoming_shipment/) [function.file-get-contents]: failed to open stream: A connection attempt failed because the connected party did not properl

我得到了下面的基本脚本,它提出了一个基本的POST请求(我只想让它工作,在我添加更多内容之后):

结果告诉我:

Warning: file_get_contents(http://******:8282/api/incoming_shipment/) [function.file-get-contents]: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in D:\Inetpub\hightechhandling\api\api_push_contract.php on line 31

Fatal error: Maximum execution time of 30 seconds exceeded in D:\Inetpub\hightechhandling\api\api_push_contract.php on line 31
但是当我用浏览器浏览网页时,它工作得非常好。我试过卷发和fsocketopen,但效果不太好。需要帮忙吗?谢谢

编辑我添加了
设置时间限制(500)现在第二个错误已经消失了当然。。。但是第一个仍然存在。

来自PHP手册 无效设置时间限制(整数$秒)

设置允许脚本运行的秒数。如果这是 到达时,脚本返回一个致命错误。默认限制为30 秒或(如果存在)中定义的最大执行时间值 php.ini

调用set_time_limit()时,将从零重新启动超时计数器。 换句话说,如果超时是默认的30秒,则为25秒 在脚本执行后的几秒钟内,将执行诸如set_time_limit(20)之类的调用 完成后,脚本将在超时前总共运行45秒。 如果设置为零,则不施加时间限制

试试这个:

'header' => implode("\r\n", array("Connection: close", "Content-type: application/x-www-form-urlencoded")),
(特别是连接:闭合位)


另外:你能用curl在共线上复制问题吗?

好的,找到了问题。太蠢了。问题在于发出请求的服务器(PHP文件所在的位置)启用了防火墙,防火墙只允许端口21、22、80、3306和1433进行外部请求

对于CentOS,使用
file\u get\u contents()
访问端口80以外的URL在权限被拒绝的情况下不起作用。只有当selinux设置为“禁用”或“允许”时,它才起作用。

如果出于安全考虑不想禁用selinux,可以修改selinux策略以允许httpd侦听8282

要列出httpd允许的端口,请执行以下操作: semanage端口-l | grep-w http|U端口

要添加端口8282,请执行以下操作:
semanage port-a-t http\u port\u t-p tcp 8282

为什么在端口8282上?该地址是否响应浏览器中的此端口?如果不是,请尝试其中一个Nmap ip地址以查看8282上的open portsMy webserver应答。。如果我以http://**.com:8282/blabla yes的形式打开URL,则webapge将在浏览器中打开。我不了解nmap ip?截至错误消息,端口不是问题…@feeela如果我使用80,我们的常规网站,它可以工作…如果你确定端口正确打开,无需使用nmap。我做了一些测试,我会还给你;)我明白,但作为一个POST请求,它不应该超过30秒。。。我的意思是最多1秒…cURL give me
无法连接到主机
但返回
TRUE
'header' => implode("\r\n", array("Connection: close", "Content-type: application/x-www-form-urlencoded")),