[英]Google Api for creating contact with php code
我创建了一个函数,在该函数中我遇到了与范围有关的错误
下面是代码:
$client = getClient();
$client->addScope(Google_Service_PeopleService::CONTACTS);
$service = new Google_Service_PeopleService($client);
$person = new Google_Service_PeopleService_Person();
$email = new Google_Service_PeopleService_EmailAddress();
$email->setValue('test@test.com');
$person->setEmailAddresses($email);
$name = new Google_Service_PeopleService_Name();
$name->setDisplayName('User de Test');
$person->setNames($name);
$phoneNumber = new Google_Service_People_PhoneNumber();
$phoneNumber->setType('Home');
$person->setPhoneNumbers($phoneNumber);
$exe = $service->people->createContact($person);
print_r($exe);*
出现如下错误:
消息:请求的身份验证范围不足。 错误:[{消息:请求的身份验证范围不足。,域:全局,原因:禁止}],状态:PERMISSION_DENIED}}
不知道您的getClient()
函数做什么。 但是,假设它像示例代码一样处理请求访问令牌,您将需要在运行逻辑以获取访问令牌之前设置作用域。 因此,可能会更改getClient()函数以为要请求的范围采用参数,并在访问令牌请求之前在其中设置范围。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.