function analyse_news(simple_html_dom_node &$newsNode) { $var = new news_def(); $var->ticker = substr_replace($newsNode->children[0]->nodes[0]->_[4], '', 0, 6); $var->time = $newsNode->children[1]->nodes[0]->_[4]; $tmp = explode(' ', $newsNode->children[4]->children[0]->nodes[0]->_[4]); $var->symbol = $tmp[0]; array_shift($tmp); $var->title = implode(' ', $tmp); if (!(stristr($var->title, 'intraday') != false && stristr($var->title, 'caution') == false)) { return NULL; } $var->link = "https://alpari-uk.tradingcentral.com" . $newsNode->children[4]->children[0]->attr['href']; $var->weekTrend = get_trend($newsNode->children[5]->children[0]->attr['src']); $var->monthTrend = get_trend($newsNode->children[7]->children[0]->attr['src']); return $var; }
<?php function get_trend() { $request = "http://kizasi.jp/kizapi.py?type=rank"; // API呼び出し $response = file_get_contents($request); //print_r($response);exit; $obj = simplexml_load_string($response); //print_r($obj );exit; $json_encode = json_encode($obj); //print_r($json_encode );exit; $result = json_decode($json_encode, TRUE); //print_r($result);exit; return $result; } print_r(get_trend());