I got the following basic script who make a basic POST request (I just want to make it work, after I’ll add more stuff) :
# 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);
The result give me :
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
But When I go to the webpage with my browser, it work perfectly. I have tryed cURL and fsocketopen but that didn’t work too. Any help please ? Thanks..
EDIT I added set_time_limit (500); and now the second error has disapear of course… but the first still remain.
Ok, found the problem. Was sooo stupid. The problem is because the server that make the request (where the PHP file is), has a firewall enabled and the firewall allow only port 21, 22, 80, 3306 and 1433 for external request.