问题描述
类型:ArgumentCountError
消息:函数Google_Client :: authenticate()的参数太少,第30行在/home/forulive/public_html/application/libraries/Google.PHP中传递了0,而恰好是期望的1
文件名:/home/forulive/public_html/application/third_party/google-api-client/vendor/google/apiclient/src/Google/Client.PHP
行号:172
Google.PHP
<?PHP defined('BASEPATH') OR exit('No direct script access allowed');
class Google{
public function __construct(){
$this->CI =& get_instance();
$this->CI->load->database();
require APPPATH .'third_party/google-api-client/vendor/autoload.PHP';
$application_name = $this->CI->db->get_where('config',array('title'=>'google_application_name'))->row()->value;
$client_id = $this->CI->db->get_where('config',array('title'=>'google_client_id'))->row()->value;
$client_secret = $this->CI->db->get_where('config',array('title'=>'google_client_secret'))->row()->value;
$redirect_uri = $this->CI->db->get_where('config',array('title'=>'google_redirect_uri'))->row()->value;
$api_key = $this->CI->db->get_where('config',array('title'=>'google_api_key'))->row()->value;
$this->client = new Google_Client();
$this->client->setApplicationName($application_name);
$this->client->setClientId($client_id);
$this->client->setClientSecret($client_secret);
$this->client->setRedirectUri($redirect_uri);
$this->client->setDeveloperKey($api_key);
$this->client->addScope('email');
$this->client->addScope('profile');
$this->client->setAccesstype('online');
$this->client->setApprovalPrompt('auto');
//$this->oauth2 = new Google_Oauth2Service($this->client);
}
public function login_url() {
return $this->client->createAuthUrl();
}
public function authenticate() {
return $this->client->authenticate();
}
public function getAccesstoken() {
return $this->client->getAccesstoken();
}
public function setAccesstoken() {
return $this->client->setAccesstoken();
}
public function revoketoken() {
return $this->client->revoketoken();
}
public function get_user_info($code) {
//It will Attempt to exchange a code for an valid authentication token.
$token = $this->client->fetchAccesstokenWithAuthCode($_GET["code"]);
//This condition will check there is any error occur during geting authentication token. If there is no any error occur then it will execute if block of code/
if(!isset($token['error']))
{
//Set the access token used for requests
$this->client->setAccesstoken($token['access_token']);
//Store "access_token" value in $_SESSION variable for future use.
//$_SESSION['access_token'] = $token['access_token'];
//Create Object of Google Service OAuth 2 class
$google_service = new Google_Service_Oauth2($this->client);
//Get user profile data from google
return $google_service->userinfo->get();
//return $this->oauth2->userinfo->get();
}
}
}
Client.PHP
尝试了很多方法,但无济于事...。如果这是重复的,那么我是新手,那么请指导我找到解决的方法。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)