/** * @获取配置文件 * @获取AccessToken */ private function initWx() { $this->initAuth(); $this->access_token = getMmemData('access_token'); if (empty($this->access_token)) { $this->initAccessToken(); } }
public function keywordLib($keyword) { $keyword = strtolower($keyword); $keywordlist = getMmemData('keywordlist'); $keywordLib = getMmemData('keywordLib'); if (empty($keywordlist)) { $keywordlist = $this->all($where = array(), array('id_keyword', 'keyword', 'cat_id', 'category')); if (!empty($keywordlist)) { setMmemData('keywordlist', $keywordlist, false, 0); } else { return array('status' => 0, 'msg' => '请在后台添加关键字,并更新入库!', 'data' => null); } } if (empty($keywordLib)) { $keywordLib = array(); foreach ($keywordlist as $Ky => $value) { $keywordLib[] = $value['keyword']; } setMmemData('keywordLib', $keywordLib, false, 0); } sort($keywordLib, SORT_STRING); $kword = ''; foreach ($keywordLib as $key => $item) { $dt[] = array('keyword' => $keyword, 'item' => $item); $result = mb_stripos($keyword, $item); if ($result !== false) { $kword = $item; break; } } if (empty($kword)) { return array('status' => 1, 'msg' => null, 'data' => null); } else { $kwordArr = array(); foreach ($keywordlist as $ky => $values) { if (in_array($kword, $values)) { $kwordArr = $values; break; } } return array('status' => 1, 'msg' => null, 'data' => $kwordArr); } }