public function parse($arg) { if (!is_string($arg)) { return; } $json = json_decode($arg, true); //转换成json格式 if (!is_array($json) || $json['result']['resultCode']['code'] != 0) { return; } foreach ($json['result']['value']['qs'] as $oneQues) { if (!isset($oneQues['id'])) { continue; } $res = json_decode(api_curl(self::$_wenTiDetailUrl . $oneQues['id'], [], 'get'), true); if (!is_array($res) || $res['result']['resultCode']['code'] != 0) { continue; } $res = $res['result']['value']; $qs = array(); $qs["content"] = $res['wenTiMm']["content"]; $qs['imgUrl'] = $res['wenTiMm']["imgUrl"]; $qs['id'] = $res['wenTiMm']["id"]; $qs['course'] = $res['wenTiMm']["course"]; $qs['answerNum'] = count($res['otherAnswers']); $qs['answer'] = $res['otherAnswers']; array_push(self::$_output, $qs); } }
/** * @throws Exception */ public function startUp() { if (is_null($this->_dev)) { throw new Exception("the dev doesn't exist"); } $count = (int) $this->_config["count"]; for ($i = 0; $i < $count; $i++) { $this->_dev->parse(api_curl($this->_dev->getUrl($i), [], "get")); } $this->_dev->output(); }