$scan_code_model::USER_ID,'rule' => 'number'), ); $check_arr = $this->checkHave($field_arr); if($check_arr[self::$error_code_name] == 0) { $header = array( 'Authorization:'.config('api_key') ); $url = 'http://www.ahmcf.cn:6176/api/Login/GetQrCode'; $params = array( 'proxyIp' => '', 'proxyUserName' => '', 'proxyPassword' => '', 'deviceID' => '', 'deviceName' => '' ); $result = ClWechat::http_post($url,$params,false,$header); $result_arr = json_decode($result,true); if (array_key_exists('Success',$result_arr)) { if ($result_arr['Success']) { $scan_code_data = array(); $scan_code_data[$scan_code_model::USER_ID] = $check_arr[self::$data_name][$scan_code_model::USER_ID]; $scan_code_data[$scan_code_model::UUID] = $result_arr['Data']['Uuid']; $add_rs = $scan_code_model->addInsertData($scan_code_model,$scan_code_data); if ($add_rs) { self::$result['QrBase64'] = $result_arr['Data']['QrBase64']; } }else { self::$result[self::$error_code_name] = 10001; } }else { self::$result[self::$error_code_name] = 10001; } }else{ if($check_arr[self::$error_code_name] == 1) { self::$result[self::$error_code_name] = 10004; self::$result[self::$error_message] = $check_arr[self::$error_message]; }else{ self::$result[self::$error_code_name] = 10001; } } } return json(self::$result); } /** * search * @return \think\response\Json */ public function search() { if(self::$result[self::$error_code_name] == 0) { $field_arr = array( array('field_name' => 'page','rule' => 'number'), array('field_name' => 'type','rule' => 'number|require'), array('field_name' => 'keyword','rule' => 'require'), array('field_name' => 'orderType','rule' => 'number'), ); $check_arr = $this->checkHave($field_arr); if($check_arr[self::$error_code_name] == 0) { $login_log_model = new LoginLog(); $login_log_where = array(); $login_log_where[$login_log_model::WORK_TYPE] = array('neq',2); $login_log_where[$login_log_model::STATUS] = 1; $login_log_info = $login_log_model->getOneById($login_log_model,$login_log_where); if (!empty($login_log_info)) { $header = array( 'Authorization:'.config('api_key') ); $url = ''; $page = 0; if (array_key_exists('page',$check_arr[self::$data_name])) { $page = $check_arr[self::$data_name]['page']; } $login_log_model = new LoginLog(); $login_log_where = array(); $login_log_where[$login_log_model::AUTO_ID] = $login_log_info[$login_log_model::AUTO_ID]; $login_log_data = array(); $login_log_data[$login_log_model::WORK_TYPE] = 2; $login_log_model->updateByWhere($login_log_model,$login_log_where,$login_log_data); $wxId = $login_log_info[$login_log_model::WXID]; $params = array(); if ($check_arr[self::$data_name]['type'] == 1) { $url = 'http://www.ahmcf.cn:6176/api/Common/SearchGh'; $params = array( 'ghName' => $check_arr[self::$data_name]['keyword'], 'page' => $page, 'wxId' => $wxId ); }elseif ($check_arr[self::$data_name]['type'] == 2) { $orderType = 0; if (array_key_exists('orderType',$check_arr[self::$data_name])) { $orderType = $check_arr[self::$data_name]['orderType']; } $url = 'http://www.ahmcf.cn:6176/api/Common/SearchGhArticle'; $params = array( 'articleName' => $check_arr[self::$data_name]['keyword'], 'page' => $page, 'orderType' => $orderType, 'wxId' => $wxId ); }elseif ($check_arr[self::$data_name]['type'] == 3) { $url = 'http://www.ahmcf.cn:6176/api/VideoFinder/SearchVideoFinder'; $page_arr = array( 'tag1' => 0, 'tag2' => 0, 'tag3' => 0, 'tag4' => 0, 'tag5' => 0, 'tag6' => 0, ); $page_str = json_encode($page_arr); $params = array( 'videoFinderName' => $check_arr[self::$data_name]['keyword'], 'page' => $page_str, 'wxId' => $wxId ); } $result = ClWechat::http_post($url,$params,false,$header); //replace // $result = str_replace('http://mmbiz.qpic.cn','http://read.html5.qq.com/image?src=forum&q=5&r=0&imgflag=7&imageUrl=http://mmbiz.qpic.cn',$result); $result_arr = json_decode($result,true); if (!empty($result_arr)) { if (array_key_exists('Success',$result_arr)) { if ($result_arr['Success']) { $tmp_json_arr = array(); if (in_array($check_arr[self::$data_name]['type'],[1,2])) { $tmp_json_str = $this->Handling_special_characters($result_arr['Data']['tag4']); $tmp_json_arr = json_decode($tmp_json_str,true); }elseif ($check_arr[self::$data_name]['type'] == 3) { $tmp_json_arr = $result_arr['Data']['VideoFinderRetContextList']; } if (!empty($tmp_json_arr)) { if (in_array($check_arr[self::$data_name]['type'],[1,2])) { $count = 0; if (array_key_exists('totalCount',$tmp_json_arr['data'][0])) { $count = $tmp_json_arr['data'][0]['totalCount']; } self::$result['count'] = $count; self::$result['lists'] = $tmp_json_arr['data'][0]['items']; }else { self::$result['count'] = 0; self::$result['lists'] = $tmp_json_arr; } $post_url = config('api_domain').'/search/add'; $post_params = array(); $post_params['debug'] = 1; $post_params['type'] = $check_arr[self::$data_name]['type']; $post_params['keyword'] = $check_arr[self::$data_name]['keyword']; $post_params['results'] = json_encode($result_arr); $post_result = ClWechat::http_post($post_url,$post_params); $post_result_arr = json_decode($post_result,true); }else { self::$result[self::$error_code_name] = 10001; } }else { self::$result[self::$error_code_name] = 10001; } }else { self::$result[self::$error_code_name] = 10001; } }else { self::$result[self::$error_code_name] = 10001; } $login_log_model = new LoginLog(); $login_log_where = array(); $login_log_where[$login_log_model::AUTO_ID] = $login_log_info[$login_log_model::AUTO_ID]; $login_log_data = array(); $login_log_data[$login_log_model::WORK_TYPE] = 0; $login_log_model->updateByWhere($login_log_model,$login_log_where,$login_log_data); }else { self::$result[self::$error_code_name] = 10001; } }else{ if($check_arr[self::$error_code_name] == 1) { self::$result[self::$error_code_name] = 10004; self::$result[self::$error_message] = $check_arr[self::$error_message]; }else{ self::$result[self::$error_code_name] = 10001; } } } return json(self::$result); } /** * advSearch * @return \think\response\Json */ public function advSearch() { if(self::$result[self::$error_code_name] == 0) { $field_arr = array( array('field_name' => 'condition','rule' => 'require'), array('field_name' => 'page','rule' => 'number|require'), array('field_name' => 'type','rule' => 'number|require') ); $check_arr = $this->checkHave($field_arr); if($check_arr[self::$error_code_name] == 0) { $pageSize = 20; $tmp_json_arr = json_decode($check_arr[self::$data_name]['condition'],true); if (!empty($tmp_json_arr)) { if (array_key_exists('keyword',$tmp_json_arr)) { $page = $check_arr[self::$data_name]['page']; $keyword = $tmp_json_arr['keyword']; $search_model = new Search(); $search_where = array(); $search_where[$search_model::TYPE] = $check_arr[self::$data_name]['type']; $search_where[$search_model::KEYWORD_MD5] = md5($keyword); $search_info = $search_model->getOneById($search_model,$search_where); if (!empty($search_info)) { $search_relation_model = new SearchRelation(); $search_relation_where = array(); $search_relation_where[$search_relation_model::KEYWORD_ID] = $search_info[$search_model::AUTO_ID]; if (array_key_exists('start_time',$check_arr[self::$data_name]) && array_key_exists('end_time',$check_arr[self::$data_name])) { $start_time = $tmp_json_arr['start_time']; $end_time = $tmp_json_arr['end_time']; $search_relation_where[$search_relation_model::SYS_CREATE_TIME] = array('between',[$start_time,$end_time]); } $search_relation_list = $search_relation_model->modelLists($search_relation_model,$page,$pageSize,$search_relation_where); $count = $search_relation_model->where($search_relation_where)->count(1); if (!empty($search_relation_list)) { $search_relation_content_id_arr = array(); foreach ($search_relation_list as $search_each_v) { $search_relation_content_id_arr[] = $search_each_v[$search_relation_model::CONTENT_ID]; } $search_content_model = new SearchContent(); $search_content_where = array(); $search_content_where[$search_content_model::AUTO_ID] = array('IN',$search_relation_content_id_arr); $search_content_list = $search_content_model->modelAllLists($search_content_model,$search_content_where); $tmp_list = array(); if (!empty($search_content_list)) { foreach ($search_content_list as $tmp_content_v) { $tmp_list[] = json_decode($tmp_content_v[$search_content_model::CONTENT],true); } } self::$result['count'] = $count; self::$result['lists'] = $tmp_list; } }else { //empty $post_url = config('api_domain').'/curl/search'; $post_params = array(); $post_params['debug'] = 1; $post_params['page'] = $check_arr[self::$data_name]['page']; $post_params['type'] = $check_arr[self::$data_name]['type']; $post_params['keyword'] = $keyword; $post_result = ClWechat::http_post($post_url,$post_params); $post_result_arr = json_decode($post_result,true); if (array_key_exists('error_code',$post_result_arr)) { self::$result['count'] = $post_result_arr['count']; self::$result['lists'] = $post_result_arr['lists']; } } } } }else{ if($check_arr[self::$error_code_name] == 1) { self::$result[self::$error_code_name] = 10004; self::$result[self::$error_message] = $check_arr[self::$error_message]; }else{ self::$result[self::$error_code_name] = 10001; } } } return json(self::$result); } /** * getWechatInfo * @return \think\response\Json */ public function getWechatInfo() { if(self::$result[self::$error_code_name] == 0) { $field_arr = array( array('field_name' => 'ghName','rule' => 'require') ); $check_arr = $this->checkHave($field_arr); if($check_arr[self::$error_code_name] == 0) { $login_log_model = new LoginLog(); $login_log_where = array(); $login_log_where[$login_log_model::WORK_TYPE] = array('neq',1); $login_log_where[$login_log_model::STATUS] = 1; $login_log_info = $login_log_model->getOneById($login_log_model,$login_log_where); if (!empty($login_log_info)) { $login_log_model = new LoginLog(); $login_log_where = array(); $login_log_where[$login_log_model::AUTO_ID] = $login_log_info[$login_log_model::AUTO_ID]; $login_log_data = array(); $login_log_data[$login_log_model::WORK_TYPE] = 1; $login_log_model->updateByWhere($login_log_model,$login_log_where,$login_log_data); $header = array( 'Authorization:'.config('api_key') ); $url = 'http://www.ahmcf.cn:6176/api/Common/GetGhArticleHistory'; $params = array( 'ghName' => $check_arr[self::$data_name]['ghName'], 'tag51' => 0, 'tag52' => 0, 'tag53' => 0, 'tag54' => 0, 'wxId' => $login_log_info[$login_log_model::WXID] ); $result = ClWechat::http_post($url,$params,false,$header); $result_arr = json_decode($result,true); if (!empty($result_arr)) { if (array_key_exists('Success',$result_arr)) { $url = $result_arr['Data']['tag4']['tag41'][0]['tag6']['tag2'][0]['tag25']; $tmp_url = 'http://www.ahmcf.cn:6176/api/Common/GetGhArticleInfo'; $tmp_params = array( 'ghName' => $check_arr[self::$data_name]['ghName'], "ghurl" => $url, "type" => 1, 'wxId' => $login_log_info[$login_log_model::WXID] ); $tmp_result = ClWechat::http_post($tmp_url,$tmp_params,false,$header); $tmp_result_arr = json_decode($tmp_result,true); self::$result['info'] = $tmp_result_arr; } }else { self::$result[self::$error_code_name] = 10001; } $login_log_model = new LoginLog(); $login_log_where = array(); $login_log_where[$login_log_model::AUTO_ID] = $login_log_info[$login_log_model::AUTO_ID]; $login_log_data = array(); $login_log_data[$login_log_model::WORK_TYPE] = 0; $login_log_model->updateByWhere($login_log_model,$login_log_where,$login_log_data); }else { self::$result[self::$error_code_name] = 10001; } }else{ if($check_arr[self::$error_code_name] == 1) { self::$result[self::$error_code_name] = 10004; self::$result[self::$error_message] = $check_arr[self::$error_message]; }else{ self::$result[self::$error_code_name] = 10001; } } } return json(self::$result); } /** * getUrl * @return \think\response\Json */ public function getUrl() { if(self::$result[self::$error_code_name] == 0) { $field_arr = array( array('field_name' => 'ghName','rule' => 'require'), array('field_name' => 'url','rule' => 'require'), array('field_name' => 'type','rule' => 'number') ); $check_arr = $this->checkHave($field_arr); if($check_arr[self::$error_code_name] == 0) { $login_log_model = new LoginLog(); $login_log_where = array(); $login_log_where[$login_log_model::WORK_TYPE] = array('neq',3); $login_log_where[$login_log_model::STATUS] = 1; $login_log_info = $login_log_model->getOneById($login_log_model,$login_log_where); if (!empty($login_log_info)) { $login_log_model = new LoginLog(); $login_log_where = array(); $login_log_where[$login_log_model::AUTO_ID] = $login_log_info[$login_log_model::AUTO_ID]; $login_log_data = array(); $login_log_data[$login_log_model::WORK_TYPE] = 3; $login_log_model->updateByWhere($login_log_model,$login_log_where,$login_log_data); $type = 0; $header = array( 'Authorization:'.config('api_key') ); $url = 'http://www.ahmcf.cn:6176//api/Common/GetGhArticleInfo'; //$check_arr[self::$data_name]['url'] = 'https://mp.weixin.qq.com/s?__biz=MzI4MDYzODg2NA==&mid=2247592801&idx=1&sn=5e94b82704c6929a5f6a6c49965e53b0&chksm=ebb64f9edcc1c688b9fa320a2d825141ba7bee0234d2ccbee689f4969e37eac4b4597ee2989a&scene=126&sessionid=1606618670#rd'; $check_arr[self::$data_name]['url'] = urldecode($check_arr[self::$data_name]['url']); if (array_key_exists('type',$check_arr[self::$data_name])) { $type = $check_arr[self::$data_name]['type']; } $params = array( 'ghName' => $check_arr[self::$data_name]['ghName'], 'ghurl' => $check_arr[self::$data_name]['url'], 'type' => $type, 'wxId' => $login_log_info[$login_log_model::WXID] ); $result = ClWechat::http_post($url,$params,false,$header); $result_arr = json_decode($result,true); if (!empty($result_arr)) { if (array_key_exists('Success',$result_arr)) { if ($type == 0) { self::$result['info_1'] = json_decode($result_arr['Data'][0],true); self::$result['info_2'] = json_decode($result_arr['Data'][1],true); }else { $tmp_str = trim($result_arr['Data'][0],'<'); self::$result['info'] = $tmp_str; self::$result['info_1'] = $result_arr['Data'][1]; self::$result['info_2'] = $result_arr['Data'][2]; } } }else { self::$result[self::$error_code_name] = 10001; } $login_log_model = new LoginLog(); $login_log_where = array(); $login_log_where[$login_log_model::AUTO_ID] = $login_log_info[$login_log_model::AUTO_ID]; $login_log_data = array(); $login_log_data[$login_log_model::WORK_TYPE] = 0; $login_log_model->updateByWhere($login_log_model,$login_log_where,$login_log_data); }else { self::$result[self::$error_code_name] = 10001; } }else{ if($check_arr[self::$error_code_name] == 1) { self::$result[self::$error_code_name] = 10004; self::$result[self::$error_message] = $check_arr[self::$error_message]; }else{ self::$result[self::$error_code_name] = 10001; } } } return json(self::$result); } /** * getArticleHistory * @return \think\response\Json */ public function getArticleHistory() { if(self::$result[self::$error_code_name] == 0) { $field_arr = array( array('field_name' => 'ghName','rule' => 'require'), array('field_name' => 'tag51','rule' => ''), array('field_name' => 'tag52','rule' => ''), array('field_name' => 'tag53','rule' => ''), array('field_name' => 'tag54','rule' => ''), ); $check_arr = $this->checkHave($field_arr); if($check_arr[self::$error_code_name] == 0) { $login_log_model = new LoginLog(); $login_log_where = array(); $login_log_where[$login_log_model::WORK_TYPE] = array('neq',4); $login_log_where[$login_log_model::STATUS] = 1; $login_log_info = $login_log_model->getOneById($login_log_model,$login_log_where); if (!empty($login_log_info)) { $this->followAccount($check_arr[self::$data_name]['ghName'],$login_log_info[$login_log_model::WXID]); $login_log_model = new LoginLog(); $login_log_where = array(); $login_log_where[$login_log_model::AUTO_ID] = $login_log_info[$login_log_model::AUTO_ID]; $login_log_data = array(); $login_log_data[$login_log_model::WORK_TYPE] = 4; $login_log_model->updateByWhere($login_log_model,$login_log_where,$login_log_data); $header = array( 'Authorization:'.config('api_key') ); $tag51 = 0; $tag52 = 0; $tag53 = 0; $tag54 = 0; if (array_key_exists('tag51',$check_arr[self::$data_name])) { $tag51 = $check_arr[self::$data_name]['tag51']; } if (array_key_exists('tag52',$check_arr[self::$data_name])) { $tag52 = $check_arr[self::$data_name]['tag52']; } if (array_key_exists('tag53',$check_arr[self::$data_name])) { $tag53 = $check_arr[self::$data_name]['tag53']; } if (array_key_exists('tag54',$check_arr[self::$data_name])) { $tag54 = $check_arr[self::$data_name]['tag54']; } $url = 'http://www.ahmcf.cn:6176/api/Common/GetGhArticleHistory'; $params = array( 'ghName' => $check_arr[self::$data_name]['ghName'], 'tag51' => $tag51, 'tag52' => $tag52, 'tag53' => $tag53, 'tag54' => $tag54, 'wxId' => $login_log_info[$login_log_model::WXID] ); $result = ClWechat::http_post($url,$params,false,$header); $result_arr = json_decode($result,true); if (!empty($result_arr)) { if (array_key_exists('Success',$result_arr)) { self::$result['info'] = $result_arr['Data']['tag4']; }else { self::$result[self::$error_code_name] = 10001; } }else { self::$result[self::$error_code_name] = 10001; } $login_log_model = new LoginLog(); $login_log_where = array(); $login_log_where[$login_log_model::AUTO_ID] = $login_log_info[$login_log_model::AUTO_ID]; $login_log_data = array(); $login_log_data[$login_log_model::WORK_TYPE] = 0; $login_log_model->updateByWhere($login_log_model,$login_log_where,$login_log_data); } }else{ if($check_arr[self::$error_code_name] == 1) { self::$result[self::$error_code_name] = 10004; self::$result[self::$error_message] = $check_arr[self::$error_message]; }else{ self::$result[self::$error_code_name] = 10001; } } } return json(self::$result); } /** * followAccount * @return \think\response\Json */ public function followAccount($account,$wxId) { $header = array( 'Authorization:'.config('api_key') ); $url = 'http://www.ahmcf.cn:6176/api/Common/FollowGHAccount'; $params = array( 'appId' => $account, 'wxId' => $wxId ); $result = ClWechat::http_post($url,$params,false,$header); $result_arr = json_decode($result,true); return $result_arr; } /** * Handling_special_characters * @param $json_str * @return mixed */ public function Handling_special_characters($json_str) { $json_str = str_replace('\\n','',$json_str); $json_str = str_replace('\\\\n\\','',$json_str); $json_str = str_replace('\\','',$json_str); $json_str = str_replace('"{','{',$json_str); $json_str = str_replace('}"','}',$json_str); $json_str = str_replace('="','=',$json_str); $json_str = str_replace('">','>',$json_str); $json_str = stripslashes($json_str); return $json_str; } }