Page 1 of 1

CURL working from localhost but not on live site

Posted: Fri Jul 30, 2010 5:55 am
by pranavkavi
I have a CURL code that fetches some XML content from a remote server. I get the expected output on my localhost (XAMPP on windows). But from the live site(hosted on Linux), I get the CURL error:'couldn't connect to host'.

Code: Select all

	function DownloadUrl($Url, $p){
	 
		// is curl installed?
		if (!function_exists('curl_init')){ 
			die('CURL is not installed!');
		}

       // create curl resource
        $ch = curl_init();

        // set url
        curl_setopt($ch, CURLOPT_URL, $Url);

	   curl_setopt ($ch, CURLOPT_POSTFIELDS, $p);
	   curl_setopt ($ch, CURLOPT_POST, 1);
        //return the transfer as a string
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

        // $output contains the output string
        $output = curl_exec($ch);
        
	   if($output === false)
		   echo 'Curl error: ' . curl_error($ch);
	   else
    		print $output;
        // close curl resource to free up system resources
        curl_close($ch);          
	}

Re: CURL working from localhost but not on live site

Posted: Fri Jul 30, 2010 5:23 pm
by pickle
Check the remote host - maybe there are access restrictions.