. All rights reserved. * Demo: http://financialplugins.com/products/stock-screener/ * Purchase: https://codecanyon.net/item/stock-screener/18297488?ref=financialtechnology * Like: https://www.facebook.com/financialplugins/ */ ?> []]; foreach ($markets as $k => $market) { $ret['markets'][$k] = $market['name']; } echo output_json_success($ret); break; case 'get-data':# GET DATA FROM SELECTED MARKET if (!isset($_POST['market']) && !isset($_GET['market'])) { echo output_json_error('Market not set'); exit; } if(isset($_GET['market'])) $mkt=(int)$_GET['market']; else $mkt=(int)$_POST['market']; if(filemtime($markets[$mkt]['file_shares_cache']) $data]); break; case 'get-share-info':#GET SHARE INFO $curl = new curl(); $share = $_POST['share']; $ret = $curl->Read(str_replace('$share', $share, $share_info_request_uri), FALSE, FALSE); $ret2 = $curl->Read(str_replace('$share', $share, $share_historical_data_uri), FALSE, FALSE); if ($ret['status'] == 200) { $data = json_decode($ret['result'], TRUE); if ($data) { $historical_data = []; if ($ret2['status'] == 200) { $result = json_decode($ret2['result'], TRUE); if (isset($result['spark']['result'][0]['response'][0]['timestamp']) && isset($result['spark']['result'][0]['response'][0]['indicators']['quote'][0]['close'])) { $timestamps = $result['spark']['result'][0]['response'][0]['timestamp']; $quotes = $result['spark']['result'][0]['response'][0]['indicators']['quote'][0]['close']; for ($i = 0; $i < count($timestamps); $i++) { $quote = floatval($quotes[$i]); if ($quote > 0) { $historical_data['dates'][] = date('d M Y', $timestamps[$i]); $historical_data['quotes'][] = $quote; } } } } echo output_json_success([ 'data' => $data, 'historical_data' => $historical_data ]); } else { echo output_json_error('There was an error while fetching the data'); } } else { echo output_json_success(['data' => [], 'historical_data' => []]); } break; default: echo output_json_error('Unknown command'); }