我一直在为 TYPO3 中的扩展开发一项功能,以将活动发布到 Google Plus 域配置文件。
我使用以下代码来实例化 Google 客户端
$googleClient = new Google_Client();
$googleClient->setApplicationName("NAME");
$googleClient->setClientId("123456789");
$googleClient->setClientSecret("qwertyuiop");
$googleClient->setRedirectUri("CALLBACK_URL");
$googleClient->setScopes(array(
'https://www.googleapis.com/auth/plus.me',
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/plus.stream.write',
));
$googleClient->setRequestVisibleActions('http://schema.org/AddAction');
$googleClient->setApprovalPrompt('force');
$googleClient->setAccessType('offline');
所有值都像令牌一样经过验证。
然后存储获取的配置文件refreshToken
多次进行 POST。现在是 POST 的代码
$googleClient->refreshToken($this->refreshToken);
$googleClient->verifyIdToken();
$plusdomains = new Google_Service_PlusDomains($googleClient);
$post = new Google_Service_PlusDomains_Activity();
$post['object']['originalContent'] = 'HELLO WORLD';
try {
$result = $plusdomains->activities->insert('me', $post);}
catch (\Exception $e){
var_dump($e);
}
try 内的行会生成一个错误,即:
由于用户已同意不兼容的范围,因此不允许访问 Google+ Domains API。请参阅: https ://developers.google.com/+/domains/authentication/
我已经搜索了有关该错误的其他信息,这表明是权限或范围,即使在几年前同一论坛的其他问题中也是如此。但是我检查了https://developers.google.com/+/domains/authentication/scopes和我正在使用的那些。我很感激你指导我解决这个问题。