(403) Legacy People API > belum pernah digunakan sebelum ini dalam projek XXXXXXXXX atau dilumpuhkan dalam Codeigniter
<p>Saya menggunakan log masuk Google dan ia berfungsi dengan baik beberapa bulan yang lalu, tetapi kini apabila saya cuba log masuk ia memberikan ralat berikut: </p>
<blockquote>
<p>Jenis pengecualian tidak tertangkap ditemui: Google_Service_Exception</p>
<p>Mesej: Ralat semasa memanggil GET
https://www.googleapis.com/plus/v1/people/me: (403) Versi lama People API
Tidak digunakan sebelum ini dalam projek XXXXXXX atau dilumpuhkan. membolehkan
mengaksesnya melalui
https://console.developers.google.com/apis/api/legacypeople.googleapis.com/overview?project=XXXXXXX
Kemudian cuba lagi. Jika anda baru-baru ini mendayakan API ini, sila tunggu beberapa minit
sebarkan ke sistem kami dan cuba semula operasi.</p>
</blockquote>
<p>Lawati pautan yang dipaparkan</p>
<pre class="brush:php;toolbar:false;">"Gagal dimuatkan."
"Terdapat ralat semasa memuatkan /apis/....googleapis.com/overview?project=<project_id> Sila cuba lagi."</pre>
<p>Saya juga mendayakan <code>People API</code></p>
<p>Tetapi masih mendapat mesej ralat yang sama</p>
<p>Saya telah mendayakan API: </p>
<p>Sila berikan sebarang penyelesaian, terima kasih</p>
<p>Kod:</p>
<pre class="brush:php;toolbar:false;"><?php
require_once('Google/autoload.php');
kelas Google {
dilindungi $CI;
fungsi awam __construct($url){
$this->CI =& get_instance();
$this->CI->muat->perpustakaan('session');
$this->CI->config->load('google_config');
$this->client = Google_Client baharu();
$this->client->setClientId($this->CI->config->item('google_client_id'));
$this->client->setClientSecret($this->CI->config->item('google_client_secret'));
$this->client->setRedirectUri($url[0]);
$this->client->setScopes(array(
"https://www.googleapis.com/auth/plus.login",
"https://www.googleapis.com/auth/plus.me",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile"
)
);
}
fungsi awam get_login_url(){
kembalikan $this->client->createAuthUrl();
}
fungsi awam mengesahkan(){
if (isset($_GET['kod'])) {
$this->client->authenticate($_GET['code']);
$_SESSION['access_token'] = $this->client->getAccessToken();
}
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
$this->client->setAccessToken($_SESSION['access_token']);
$plus = Google_Service_Plus baharu($this->client);
$orang = $tambah->orang->dapat('saya');
$info['id']=$person['id'];
$info['email']=$person['email'][0]['value'];
$info['name']=$person['displayName'];
$info['link']=$person['url'];
$info['profile_pic']=substr($person['image']['url'],0,strpos($person['image']['url'],"?sz=50")) . '?sz=800';
kembalikan $info;
}
}
}</pra>
<blockquote>
<p>GoogleConfig.php</p>
</blockquote>
<pre class="brush:php;toolbar:false;">$config['google_client_id']="XXXX.apps.googleusercontent.com";
$config['google_client_secret']="XXXX";</pre>
<p>控制器:</p>
<pre class="brush:php;toolbar:false;">$this->load->library('google',array(base_url().$this->config->item(' google_redirect_url_signin')));
$this->data['google_redirect_url_signin']=$this->google->get_login_url();</pre>
<p>查看:</p>
<pre class="brush:php;toolbar:false;"><button onclick="location.href ='<?=$google_redirect_url_signin?>';" class="log masukBtn loginBtn--google">
Log masuk dengan Google
</button></pre></p>