7 function getISIN($stockcode, $exchange)
9 $ar = explode('.', $stockcode);
12 // get isin by exchange
17 return $this->getExchangeISIN($stockcode, $exchange);
25 return $this->getExchangeISIN($ar[0], 'EURONEXT');
28 // get isin by location
30 $file = dirname(__FILE__) . '/ISIN/' . $ar[1] . '.php';
32 // invalid / not supported
33 if(!file_exists($file)) {
39 $cls = 'Finance_ISIN_' . $ar[1];
41 // invalid / not supported
42 if(!class_exists($cls)) {
47 return $c->getLocationISIN($stockcode);
50 // data from Trading View (A more reliable source should be used if found)
52 function getExchangeISIN($stockcode, $exchange)
54 $ar = explode('.', $stockcode);
57 curl_setopt($ch, CURLOPT_URL, 'https://www.tradingview.com/symbols/' . $exchange . '-' . $stockcode .'/');
58 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
59 $str = curl_exec($ch);
63 preg_match('/window.initData.symbolInfo = ({.*});/', $str, $matches);
69 $ret = json_decode($matches[1]);
71 if(!empty($ret->isin)) {
78 function getLocationISIN($stockcode)
80 return isset($this->map[$stockcode]) ? $this->map[$stockcode] : false;