【发布时间】:2012-08-21 16:48:11
【问题描述】:
我得到了以下基本脚本,它发出一个基本的 POST 请求(我只是想让它工作,在我添加更多东西之后):
# Variables
$URL = 'http://******:8282/api/incoming_shipment/';
$postdata = http_build_query(
array(
'contract_id' => 'Showcare-R124276',
'shipment_from' => 'Montréal',
'shipment_to' => 'Chicago',
'shipping_time' => '2012-08-16 14:51:01',
'tracking_cie' => 'Poste Canada',
'tracking_type' => 'Standard',
'tracking_number' => 'EP645 9834 123 9773'
)
);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$result = file_get_contents($URL, FALSE, $context);
print_r($result);
结果给我:
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
但是当我使用浏览器访问网页时,它运行良好。我已经尝试过 cURL 和 fsocketopen 但这也没有用。请问有什么帮助吗?谢谢..
编辑我添加了set_time_limit (500);,现在第二个错误当然消失了……但第一个错误仍然存在。
【问题讨论】:
-
为什么在端口 8282 上?该地址是否响应浏览器中的此端口?如果没有,请尝试使用 Nmap ip 地址之一查看打开的端口
-
我的网络服务器回答 8282 .. 如果我将 URL 打开为 http://****.com:8282/blabla 是的,webapge 在浏览器中打开。我不明白 nmap ip 吗?
-
从报错信息来看,端口不是问题……
-
@feeela 如果我使用我们的常规网站 80,它可以工作...
-
如果您确定端口打开正确,则无需使用nmap。我做了一些测试,我会回馈;)
标签: php post file-get-contents