I am using yahoo’s finance stock quotes to get the stock ticker data from their api .
To grab the data using
$data = file_get_contents("http://quote.yahoo.com/d/quotes.csv?s=appl&f=sl1d1t1c1ohgv&e=.csv");
$values = explode(",", $data);
echo '<pre>';
print_r($values);
Now this works perfectly fine in my local server (localhost) , i.e $values are echoed out .
But when i upload this file onto my server ,it prints out the URL : http://quote.yahoo.com/d/quotes.csv?s=appl&f=sl1d1t1c1ohgv&e=.csv . I know there is some issue with the file_get_contents on the server . Even allow_url_fopen is set to ‘ON’ on the server .Just cant seem to figure out the issue on the server end .
You probably are having problems with server settings not letting you use
file_get_contents(). In PHPcurlwill be your friend when trying to pull in content from other domains.I just found this awesome little snippet: http://snipplr.com/view/4084
It’s a function to replicate the functionality of
file_get_contents()but usescurl:Your new code would look like this: