7 function getISIN($stockcode, $exchange)
9 $ar = explode('.', $stockcode);
12 // get isin by exchange
17 return $this->getExchangeISIN($stockcode, $exchange);
19 return $this->getExchangeISIN($stockcode, 'EURONEXT');
27 // get isin by location
29 $file = dirname(__FILE__) . '/ISIN/' . $ar[1] . '.php';
31 // invalid / not supported
32 if(!file_exists($file)) {
38 $cls = 'Finance_ISIN_' . $ar[1];
40 // invalid / not supported
41 if(!class_exists($cls)) {
46 return $c->getLocationISIN($stockcode);
49 // data from Trading View (A more reliable source should be used if found)
51 function getExchangeISIN($stockcode, $exchange)
53 $ar = explode('.', $stockcode);
56 curl_setopt($ch, CURLOPT_URL, 'https://www.tradingview.com/symbols/' . $exchange . '-' . $stockcode .'/');
57 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
58 $str = curl_exec($ch);
62 preg_match('/window.initData.symbolInfo = ({.*});/', $str, $matches);
68 $ret = json_decode($matches[1]);
70 if(!empty($ret->isin)) {
77 function getLocationISIN($stockcode)
79 return isset($this->map[$stockcode]) ? $this->map[$stockcode] : false;