This commit is contained in:
wangjinlei
2024-11-15 09:29:58 +08:00
parent 11560a503c
commit 0563c1217b
2 changed files with 156 additions and 38 deletions

View File

@@ -622,19 +622,23 @@ class User extends Base
if($data['type']==0){//wos
$user_info['wos_index'] = $data['index'];
$user_info['wos_time'] = time();
$this->user_obj->update($user_info);
}elseif ($data['type']==1){//scopus
$user_info['scopus_index'] = $data['index'];
$user_info['scopus_time'] = time();
$user_info['scopus_website'] = $data['website'];
$user_info['scopus_editor'] = $editor_info['realname'];
$this->user_obj->update($user_info);
}else{//google
$user_info['google_index'] = $data['index'];
$user_info['google_time'] = time();
$user_info['g_author'] = $data['g_author'];
$user_info['g_website'] = $data['website'];
$user_info['google_editor'] = $editor_info['realname'];
if(isset($data['g_author'])&&$data['g_author']!=null&&$data['g_author']!=""){
$this->googleBindAuthorNew($data['user_id'],$data['g_author']);
}else{
$user_info['google_index'] = $data['index'];
$user_info['google_time'] = time();
$user_info['google_editor'] = $editor_info['realname'];
$this->user_obj->update($user_info);
}
}
$this->user_obj->update($user_info);
return jsonSuccess($user_info);
}
@@ -1624,6 +1628,28 @@ class User extends Base
return jsonSuccess($organic_results);
}
private function googleBindAuthorNew($user_id,$g_author){
$this->user_obj->where('user_id',$user_id)->update(['g_author'=>trim($g_author)]);
//绑定完成后自动获取指数
Loader::import("google.google-search-results");
Loader::import("google.restclient");
$query = [
"engine" => "google_scholar_author",
"author_id" => trim($g_author)
];
$search = new \GoogleSearch('7651ca6caf949b0ac6ce28a95f3d2e9d8ee51b024ba7fad86f0298fb84290765');
$result = $search->get_json($query);
$organic_results = object_to_array($result);
$h_index= 0;
$h_index = $organic_results['cited_by']['table'][1]['h_index']['all'];
$updata['google_index'] = $h_index;
$updata['google_time'] = time();
$this->user_obj->where('user_id',$user_id)->update($updata);
}
/**
* 获取H指数
*/