Link to home
Start Free TrialLog in
Avatar of Paul Konstanski
Paul KonstanskiFlag for United States of America

asked on

CURL Request Stopped working

For years I've been running a daily curl script that tracks stock quotes through Yahoo finance.  Just the other day the CURL request stopped working.

The URL that I'm using works fine in a browser and gives me the option of downloading the CSV. Here is the URL:
http://download.finance.yahoo.com/d/quotes.csv?s=AAWW+ATTU+CJES+CLRO&f=sd1noghl1vpt7t8erdjka2j4j1m3m4w1ba

If you click on this link it will ask you about opening a CSV file on your computer which gives the exact fields that I want.

Previously this worked fine using a CURL request. But as of last Thursday something changed.  It may be that Yahoo changed something or my PHP version may have been upgraded on my hosting server which caused something to not work.  

Here's the code that worked fine until last Thursday.

       $url = "http://download.finance.yahoo.com/d/quotes.csv?s=AAWW+ATTU+CJES+CLRO&f=sd1noghl1vpt7t8erdjka2j4j1m3m4w1ba";
	$ch = curl_init(); 
	curl_setopt($ch, CURLOPT_URL, $url); 
	curl_setopt($ch, CURLOPT_HEADER, 0); 
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
	$var = curl_exec($ch); 
	curl_close($ch);
	print 'CURL RESPONSE: <textarea cols=100 rows=25>'.$var.'</textarea>'; die ("at stockPull stop point");

Open in new window


In the past, this textarea would show the same data that you see from going straight to the URL. But now it just gets caught in a loop that gives an error message in the logs of:
mod_fcgid: read data timeout in 120 seconds, referer: http://www.mydomain.com/look.php?a=new
Premature end of script headers: look.php, referer: http://www.mydomain.com/look.php?a=new

Any insight into why the CURL request no longer works would be appreciated.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Kimputer
Kimputer

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Paul Konstanski

ASKER

Thanks for testing it.

It got me thinking that maybe I should test on one of my other servers which I did and it works fine.

I'm doing some research to see if I can determine what setting on the machine may have changed.
cURL returns error information when it fails.  If you want to see a code sample that will help visualize it, please post a Q and I'll be glad to show you what PHP can tell you about.
Ray,

I posted the question here:
https://www.experts-exchange.com/questions/28668385/Curl-Error-Reporting-for-PHP.html

The points away... :)

Thanks.

Paul