我得到了以下基本脚本,它发出基本的 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);
,现在第二个错误当然消失了......但第一个错误仍然存在。