gpt4 book ai didi

google-oauth - 谷歌人 API "Request mask cannot be empty"

转载 作者:行者123 更新时间:2023-12-04 13:30:57 25 4
gpt4 key购买 nike

我正在尝试请求通过 Google OAuth 登录的用户的个人资料信息。我的请求格式正确,我成功登录,但是当我尝试在 PHP 中发出以下请求时,出现错误 请求掩码不能为空。有效路径为: ...

然而,从Google People API people.get documentation中可以清楚地看出请求掩码值是可选的,如果没有通过,will return all values except for people.connections.list .这是我的代码:

// The entire OAuth process works up until this point...
// create the service
$service = new Google_Service_People($this->client);

try {
$results = $service->people->get('people/me');
} catch(\Exception $exception) {
echo $exception->getMessage();
exit;
}

这是我从这个错误中得到的异常消息:
{ "error": { "code": 400, "message": "Request mask can not be empty. Valid paths are: [person.addresses, person.age_ranges, person.biographies, person.birthdays, person.bragging_rights, person.cover_photos, person.email_addresses, person.events, person.genders, person.im_clients, person.interests, person.locales, person.memberships, person.metadata, person.names, person.nicknames, person.occupations, person.organizations, person.phone_numbers, person.photos, person.relations, person.relationship_interests, person.relationship_statuses, person.residences, person.skills, person.taglines, person.urls].", "errors": [ { "message": "Request mask can not be empty. Valid paths are: [person.addresses, person.age_ranges, person.biographies, person.birthdays, person.bragging_rights, person.cover_photos, person.email_addresses, person.events, person.genders, person.im_clients, person.interests, person.locales, person.memberships, person.metadata, person.names, person.nicknames, person.occupations, person.organizations, person.phone_numbers, person.photos, person.relations, person.relationship_interests, person.relationship_statuses, person.residences, person.skills, person.taglines, person.urls].", "domain": "global", "reason": "badRequest" } ], "status": "INVALID_ARGUMENT" } }
谁能帮我吗?

更新 1:

当我尝试为请求掩码传递一些值时, $service->people->get('people/me', array("person.names"));我收到异常消息: Illegal string offset 'type'

最佳答案

为时已晚,但也许这对其他人有用。

使用下面的数组作为第二个参数来添加带有 api 调用的 requestMask

$optParams = array('requestMask.includeField'=>'person.names' );

关于google-oauth - 谷歌人 API "Request mask cannot be empty",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43901706/

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