php - Google finance returns null -
i using curl retrieve value of current share price , have created several cron jobs update value of share every 20 minutes or so. yesterday working fine today returning null object , using curl value retrieval.
here code:
$sourceurl = 'http://www.google.com/finance/info?infotype=infoquoteall&q='.$row[1].':'.$main_id; echo $sourceurl."<br/>"; $ch = curl_init(); $timeout = 5; // set 0 no timeout curl_setopt ($ch, curlopt_url, $sourceurl); curl_setopt ($ch, curlopt_returntransfer, 1); curl_setopt ($ch, curlopt_connecttimeout, $timeout); $sourcedata = curl_exec($ch); curl_close($ch); $json = str_replace("\n", "", $sourcedata); //remove //, [ , ] build qualified string $data = substr($json, 4, strlen($json) -5);
//decode json data
$json_output = json_decode(utf8_decode($data)); var_dump($json_output);
//output stock price //update_in_db returns query string in bottom
$query=update_in_db($json_output,$main_id); $result_query=mysqli_query($dbc,$query); if($result_query===false) { echo mysqli_error($dbc)."<br/>"; } echo "done<br/>";`
this working fine said update_in_db reurns this:
update `stock_table` set `stock_curr_val`=0, `stock_change`=0, `stock_change_p`=0, stock_open_val`=0, `stock_hi_val`=0, `stock_low_val`=0, `stock_volume`='0', stock_hi_52`=0, stock_low_52`=0, `stock_market_cap`='0' `stock_symbol`='20microns';
thanks help.
Comments
Post a Comment