Hi I'm trying to use curl to make a request to a remote server, and for what ever reason it keeps timing out. I've tested this code on another server and it works fine. I've tried several sites including, google.com, yahoo.com, bing.com, ebay.com and facebook.com. I'm pretty sure that all those sites wouldnt be down at the same time. Which makes me wonder if there is something wrong with the specific server I am on. Here is the code for argument sakes, its pretty simple and pretty much a copy/paste from the php manual. Also I am on the basic shared hosting plan. I have checked the php config and curl is enabled, and allow_url_fopen is set to On.
Thanks for your help in advance.PHP Code:<?php
$ch = curl_init("http://www.facebook.com/");
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_PORT, 80);
//echo the results
echo curl_exec($ch);
//echo the error message
echo curl_error($ch);
// close cURL resource, and free up system resources
curl_close($ch);
?>


Reply With Quote

