gpt4 book ai didi

php - 使用 LightOpenID 获取 Google 通讯录?

转载 作者:可可西里 更新时间:2023-11-01 12:55:54 24 4
gpt4 key购买 nike

我目前正在使用 LightOpenID 允许用户登录我的站点,我可以在其中自动提取他们的用户名和电子邮件地址:

$openid->required = array('namePerson/first', 'namePerson/last', 'contact/email');
$openid->identity = 'https://www.google.com/accounts/o8/id';

我在这里使用参数 namePerson/firstnamePerson/lastcontact/email

我知道为了获得用户联系人列表,我必须使用提要:

https://www.google.com/m8/feeds

但是,我似乎无法弄清楚为此需要使用哪些参数?

如果我完全删除参数行,我只会得到一个空数组。

谁能帮我弄清楚获取联系人需要哪些参数?

这是我目前的代码:

<?php
require '/var/www/libraries/openid.php';

try {

$openid = new LightOpenID;

if(!$openid->mode) {

//$openid->required = array('gd/fullName');
$openid->identity = 'https://www.google.com/m8/feeds/contacts/oshirowanen.y%40gmail.com/full';
header('Location: ' . $openid->authUrl());
exit;

} elseif($openid->mode == 'cancel') {

echo "cancelled";
exit;

} else {

if ( $openid->validate() ) {

$returned = $openid->getAttributes();
print_r($returned);

exit;

} else {

echo "something is wrong";
exit;

}

}

} catch(ErrorException $e) {

echo $e->getMessage();

}
?>

最佳答案

你不能用 LightOpenID 做到这一点,因为它只实现了 OpenID 协议(protocol)。

您将需要 OAuth (2.0) 协议(protocol)来执行此操作。每the docs :

About authorization protocols

We recommend using OAuth 2.0 to authorize requests.

If your application has certain unusual authorization requirements, such as logging in at the same time as requesting data access (hybrid) or domain-wide delegation of authority (2LO), then you cannot currently use OAuth 2.0 tokens. In such cases, you must instead use OAuth 1.0 tokens and an API key. You can find your application's API key in the Google API Console, in the Simple API Access section of the API Access pane.

关于php - 使用 LightOpenID 获取 Google 通讯录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11176915/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com