我正在尝试使用 Google People API 添加和更新我的 Google 联系人。我已经使用 Google 文档 ( https://developers.google.com/people/v1/getting-started ) 中给出的示例代码几乎逐字设置了 API 。我收到以下代码行的错误,它再次来自文档的逐字记录:
$profile = $people_service->people->get('people/me', array('personFields' => 'names,emailAddresses'));
Run Code Online (Sandbox Code Playgroud)
错误如下:
Fatal error: Uncaught exception 'Google_Exception' with message '(get) unknown parameter: 'personFields'' in /home/danbak15/bakerlegalservicesmo.com/office/google-api-php-client-2.2.0/src/Google/Service/Resource.php:147 Stack trace: #0 /home/danbak15/bakerlegalservicesmo.com/office/google-api-php-client-2.2.0/vendor/google/apiclient-services/src/Google/Service/People/Resource/People.php(52): Google_Service_Resource->call('get', Array, 'Google_Service_...') #1 /home/danbak15/bakerlegalservicesmo.com/office/BLScontacts.php(36): Google_Service_People_Resource_People->get('people/me', Array) #2 {main} thrown in /home/danbak15/bakerlegalservicesmo.com/office/google-api-php-client-2.2.0/src/Google/Service/Resource.php on line 147
Run Code Online (Sandbox Code Playgroud)
我看到了类似问题的答案(访问 google-people API 时无法访问我的个人资料数据)建议使用 Google_Service_PeopleService 类而不是文档中要求的 Google_Service_People 类。但是,当我尝试执行此操作时,出现另一个错误:
Fatal error: Uncaught exception 'Google_Service_Exception' with message '{ "error": { "code": 401, "message": "Request had invalid …Run Code Online (Sandbox Code Playgroud) 对于我正在开发的应用程序,它使用使用凭据(用户登录)的 People API。一旦用户提供凭据,我就可以访问各种 Google API,例如 People API。一个例子是获取联系人列表:
https://developers.google.com/people/api/rest/v1/people.connections/list
我注意到该类com.google.api.client.googleapis.auth.oauth2.GoogleCredential已被弃用:
该应用程序具有基于一些旧 G+ 代码(此处)的旧代码,可通过 Google 帐户联系联系人。这是其中最重要部分的一个片段,这让我无法迁移它:
object GoogleOuthHelper {
@WorkerThread
fun setUp(context: Context, serverAuthCode: String?): Services {
val httpTransport: HttpTransport = NetHttpTransport()
val jsonFactory = JacksonFactory.getDefaultInstance()
// Redirect URL for web based applications. Can be empty too.
val redirectUrl = "urn:ietf:wg:oauth:2.0:oob"
// Exchange auth code for access token
val tokenResponse = GoogleAuthorizationCodeTokenRequest(
httpTransport, jsonFactory, GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET,
serverAuthCode, redirectUrl)
.execute()
// Then, create a GoogleCredential object …Run Code Online (Sandbox Code Playgroud) Google People API,Google Plus API不为响应中的id每个Person资源提供唯一的。
为什么这已被弃用/删除,以及如何Person在没有id.
https://developers.google.com/people/api/rest/v1/people/updateContact
这是使用 People API 更新联系人的 wiki。该更新适用于“emailAddresses”等字段。但是“coverPhotos”或“photos”没有被列为“updatePersonFields”的有效值,如果我尝试更新它们,我会得到返回码 400。
此 API 是否支持更改联系人的照片?或者有没有其他 API 可以完成这项工作?
根据Google People API的文档,我正在使用配置文件范围 - https://www.googleapis.com/auth/user.phonenumbers.read和PersonFields=phoneNumbers仅在其 Google 配置文件中读取经过身份验证的用户的电话号码(没有来自联系人列表)。我正在使用 API 密钥和 oAuth 访问令牌来授权请求。google people API 不会单独获取与上述范围的个人资料关联的电话号码。除了上述范围之外,还添加了整个联系人列表读取权限的范围,即www.googleapis.com/auth/contacts.readonly正确返回个人资料中的电话号码. 有没有办法从他/她的个人资料中获取用户的电话号码仅使用 user.phonenumbers.read 范围?
正如在此 SO线程中所解释的那样,无法使用 People API 获取“其他联系人”。我想知道 Google 是否打算这样做?例如,由于 Go 不支持 Contacts API 而只支持 People API,这意味着我们将失去访问其他联系人的可能性,这对于使用 Google 联系人的应用程序中的自动完成功能来说非常烦人..谢谢!
我正在使用 Google People API 从 Node JS 客户端获取用户帐户信息(仅适用于使用 Gmail API 通过 gmail 登录授权的用户)。我想确保我使用的 people.get 方法不会受到关闭 Google+ 及其 API 的影响。
这是谷歌于 2018 年 12 月 20 日发送的通知开发人员关闭的电子邮件的摘录:
"注意:如果您看到对 people.get 的调用,这可能是在您的应用程序中使用 Google+ 登录功能的结果,该功能现已完全弃用并正在关闭。开发人员应从 Google+ 登录功能迁移到更全面的 Google 登录身份验证系统。”
如上所述,我使用 People API 来调用 people.get,但我不清楚这是否会受到 Google+ 弃用的影响。
Google 通讯录允许我们通过传递 * 而不是联系人当前的 Etag 来绕过 Etag 验证以进行编辑/删除请求。
注意:特殊的 Etag 值 * 可用于绕过此验证并处理更新,而不管来自其他客户端的更新如何。
有没有类似的方法可以绕过People API 中编辑/删除的 Etag 验证?
如果在更新期间没有在 Person 对象中发送 etag 值,则会面临以下错误。值“ * ”在 People API 中也不起作用。
要求:
{
"emailAddresses": [
{
"displayName": "test1@gmail.com",
"value": "test1@gmail.com",
"type": "home"
}
]
}
Run Code Online (Sandbox Code Playgroud)
回复:
{
"error": {
"code": 400,
"message": "Request must set person.etag or person.metadata.sources.etag for the source that is being updated.",
"status": "INVALID_ARGUMENT"
}
}
Run Code Online (Sandbox Code Playgroud) 我们使用 Google Contacts API 来获取在特定时间后更新的联系人条目,以在我们端保留联系人的更新副本。
在 Google Contacts API 中,有一个选项可以使用“updated-min”查询参数在特定时间后更新联系人条目。
GET https://www.google.com/m8/feeds/contacts/default/full?updated-min=2007-03-16T00:00:00
Run Code Online (Sandbox Code Playgroud)
在 Google People 文档中没有针对这种情况在 Google People API 中指定选项。我错过了什么还是没有提供这个功能?
我正在开发一个需要获取“其他联系人”信息的应用程序,因为它们出现在Google 的“联系人”网站上的地址簿页面上:
Contacts API 已被弃用,我们需要使用 People API。
为此,我使用了 Java 库(此处),它可以更轻松地访问各种功能。
遗憾的是,根据文档(此处),从“其他联系人”查询项目列表,您最多只能获得 3 个可能的字段:
确实,在使用它时,这就是我得到的。我也有“etag”和“resourceName”字段,但就是这样。没有照片,没有封面照片,没有别的……
执行此操作的代码很短(在您设置好所有内容之后):
val otherContactsResponse =
otherContacts.list().setReadMask("emailAddresses,names,phoneNumbers")
.setPageSize(itemsCountToRequest).setPageToken(nextPageToken).execute()
val result=otherContactsResponse.otherContacts
Run Code Online (Sandbox Code Playgroud)
result.forEach { personBasic: Person ->
val test: Person? = peopleService.get(personBasic.resourceName!!)
.setPersonFields(
"addresses,ageRanges,birthdays,coverPhotos,emailAddresses,genders,metadata,names,nicknames,occupations,organizations,phoneNumbers,photos,urls")
.execute()
Log.d("AppLog", "$test")
}
Run Code Online (Sandbox Code Playgroud)
遗憾的是,没有类似的搜索“其他联系人”部分的查询(除了这里,它再次为您提供相同的 3 个字段)。
试图找出我遗漏的其他字段是否可以在其他地方使用。我甚至不知道resourceName或者etag是可靠和查询唯一的。
尽管文档只讨论了 3 个字段,但仍尝试向查询添加更多字段。失败了,当然...
有一个名为copyOtherContactToMyContactsGroup( here )的函数,它似乎会将联系人复制到主要联系人组。我想如果我使用它然后查询联系人本身(不仅仅是“其他联系人”),我可以获得所需的信息。但这既浪费时间,又会污染用户的通讯录,即使是暂时的。我必须确保在添加联系人后立即从那里删除联系人...
编辑:也试过这个,虽然它似乎有效,但我不想使用它,因为它会用用户尚未添加的联系人污染地址簿。另外,我有时会得到一个图像,它只是带有背景的人的字母。这是它的代码:
result.firstOrNull { !it.names.isNullOrEmpty()&&!it.emailAddresses.isNullOrEmpty() …Run Code Online (Sandbox Code Playgroud)