Page 1 of 1

help with curl

Posted: Tue Sep 09, 2008 1:10 am
by chimanrao
here is the snippet below, i keep getting curl error number 7, couldn't connect to host.
I tried using the IP address instead of the URL.

Code: Select all

 
        $url = "http://www.google.com";
 
        $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
                                                curl_setopt($ch, CURLOPT_VERBOSE, 1);
            curl_setopt($ch, CURLOPT_HEADER, 1);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                                                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        $data = curl_exec($ch);
 
        //Error Checking
        echo "<pre>";
        print_r(curl_getinfo($ch));
        echo "\n\nErrorNum: " . curl_errno($ch);
        echo "\n\nError: " . curl_error($ch);
        echo "</pre>";
        
        curl_close($ch);
        echo $data;
 
 

Re: help with curl

Posted: Tue Sep 09, 2008 9:42 am
by andyhoneycutt
I have no problem executing this code on my test box. Works fine. Can the machine that you are using to execute this code ping http://www.google.com?

-Andy

Re: help with curl

Posted: Wed Sep 10, 2008 11:39 am
by chimanrao
I am not sure how to execute this, its a hosted website, I have only ftp access to it.
The host is http://www.3shost.com
When I logged the service request, the arrogant technical specialist said my code might be wrong..

is there any other way I can test this?

Re: help with curl

Posted: Wed Sep 17, 2008 9:24 am
by andyhoneycutt
Sorry for the late reply! I've been away. cURL isn't a part of the default installation of the php5 package, with default options, so your host may not have it available. They may also be denying use of cURL out of some security guideline they have. You may try using fopen() or some other less robust function/object to handle what you're trying to do.

-Andy