file_get_contents() not working in yahoo host
i an displaying live stock quotes using $data = file_get_contents("http://quote.yahoo.com/d/quotes.csv?s=$symbol&f=sl1d1t1c1ohgv&e=.csv");
but i am using yahoo host. it doesnot allowing allow_url to change even not uploading .htaccess file. so how can i display live stock开发者_开发知识库 quotes in my webste.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://quote.yahoo.com/d/quotes.csv?s=$symbol&f=sl1d1t1c1ohgv&e=.csv');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec();
curl_close($ch);
?>
Use cURL :) Much better!
You can use cURL as mentioned by the other responses, but if they have disabled URL file-access I doubt cURL would work either.
The only way you could do it is have your PHP script hosted somewhere else that allows this and use Javascript to fetch the data using AJAX.
精彩评论