Jump to content

CURL help: http_code => 0


parterburn

Recommended Posts

Need some help...been fighting a CURL request for a while now and can't seem to figure out the issue. The same code is working on different URL's and returning responses as expected so I'm wondering how to get around the issue that this particular URL is giving me.

 

It seems like I've tried using all the Header, Post & Cookie options possible in curl, but maybe not :)

 

Output of curl_getinfo:

Array ( [url] => http://www.reis.com/submarketlookup/index.cfm?event=enterProp [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0 [namelookup_time] => 0.004341 [connect_time] => 0 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 [starttransfer_time] => 0 [redirect_time] => 0 ) 

 

Code being used:

                $c = curl_init();
                curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($c, CURLOPT_URL, "http://www.reis.com");
	curl_setopt($c, CURLOPT_TIMEOUT, 10);
                $contents = curl_exec($c);
	print_r(curl_getinfo($c));
                curl_close($c);

Link to comment
https://forums.phpfreaks.com/topic/192466-curl-help-http_code-0/
Share on other sites

Nothing wrong with your code(?) though your $contents is redirecting <head><meta http-equiv="Refresh" content="0; URL=index.cfm">

 

Array
(
    [url] => http://www.reis.com/
    [content_type] => text/html; charset=UTF-8
    [http_code] => 200
    [header_size] => 242
    [request_size] => 51
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0.165
    [namelookup_time] => 0
    [connect_time] => 0.051
    [pretransfer_time] => 0.051
    [size_upload] => 0
    [size_download] => 88
    [speed_download] => 533
    [speed_upload] => 0
    [download_content_length] => 88
    [upload_content_length] => 0
    [starttransfer_time] => 0.165
    [redirect_time] => 0
)

 

 

 

Same results, even with followlocation in there...I wonder if it has something to do with my server or PHP.INI settings?

 

http://www.sixteenseven.com/reis_test.php

 

		$c = curl_init();
        curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($c, CURLOPT_FOLLOWLOCATION, TRUE);
	curl_setopt($c, CURLOPT_URL, "http://www.reis.com");
	curl_setopt($c, CURLOPT_TIMEOUT, 10);
        $contents = curl_exec($c);
	print_r(curl_getinfo($c));
        curl_close($c);
	echo "<br><br><br><br>";
	echo $contents;
	echo phpinfo();

You curl is enabled with what it needs to do anything. I'm kinda lost.

 

A couple of suggestions.

Add a user-agent. Its possible that the server is locking you out as a bothersome bot after a few to many accesses.

 

If you are using windows do the usual reboot to get rid of any of Billy's gremlins. You could also try turning off your firewall if you have one running.

 

 

HTH

Teamatomic

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.