在my google plus中,插入一个活动,使用;域名谷歌+;空气污染指数;还有PHP。我犯了一个错误

在my google plus中,插入一个活动,使用;域名谷歌+;空气污染指数;还有PHP。我犯了一个错误,php,google-api,google-plus,google-domain-api,Php,Google Api,Google Plus,Google Domain Api,这是我插入活动的代码: const SERVICE_ACCOUNT_EMAIL = "xxxxxx"; const KEY_FILE = 'key.p12'; $client_id = 'yyyyyyyyy'; $client_secret = 'zzzzzzzzz'; $redirect_uri = 'ttttttttt'; $client = new Google_Client(); $client->setApplicationName("P

这是我插入活动的代码:

const SERVICE_ACCOUNT_EMAIL = "xxxxxx";
const KEY_FILE = 'key.p12'; 
$client_id     = 'yyyyyyyyy';
$client_secret = 'zzzzzzzzz';
$redirect_uri  = 'ttttttttt';
$client = new Google_Client();
$client->setApplicationName("Prueba_social123");

$key = file_get_contents(KEY_FILE);
$user_credentials = new Google_Auth_AssertionCredentials(
  SERVICE_ACCOUNT_EMAIL,
  array("https://www.googleapis.com/auth/plus.me",
        "https://www.googleapis.com/auth/plus.stream.write"),
  $key);    

$user_credentials->sub = "xxxxxxxxx@gmail.com";
$client->setAssertionCredentials($user_credentials);

$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setRedirectUri($redirect_uri);
$client->setDeveloperKey('wwwwwwwwwwwwwwwwwwwwww');

$client->setScopes(array('https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/plus.me', 'https://www.googleapis.com/auth/plus.login', 'https://www.googleapis.com/auth/plus.stream.write') );

$plus     = new Google_Service_Plus($client);
$oauth2   = new Google_Service_Oauth2($client);


if (isset($_REQUEST['logout'])) {
  unset($_SESSION['access_token']);
}


if (isset($_GET['code'])) {
   $client->authenticate($_GET['code']);
   $_SESSION['access_token'] = $client->getAccessToken();
   $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
   header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
}


if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
   $client->setAccessToken($_SESSION['access_token']);

} else {
   $authUrl = $client->createAuthUrl();
}


if ($client->getAccessToken()) {
 $_SESSION['access_token'] = $client->getAccessToken();
 $token_data = $client->verifyIdToken()->getAttributes();

 $plusdomains = new Google_Service_PlusDomains($client);
 $activityObject = new Google_Service_PlusDomains_ActivityObject();
 $activityObject->setOriginalContent("Prueba de actividad desde la API de mensajes123");
 $activityAccess = new Google_Service_PlusDomains_Acl();
 $activityAccess->setDomainRestricted(true);
 $resource = new Google_Service_PlusDomains_PlusDomainsAclentryResource();
 $resource->setType("public");

 $resources = array();      
 $resources[] = $resource;
 $activityAccess->setItems($resources);

 $activity = new Google_Service_PlusDomains_Activity();
 $activity->setObject($activityObject);
 $activity->setAccess($activityAccess);
 $plusdomains->activities->insert("me", $activity);
 
 ....................
我得到了一个错误:

致命错误:未捕获的异常“Google\u服务\u异常”与 “邮件”调用POST时出错 : (403)禁止进入 /var/www/html/public/pruebas_sociales/google-api/src/google/Http/REST.php:79 堆栈跟踪:#0 /var/www/html/public/pruebas_sociales/google-api/src/google/Http/REST.php(44): Google_Http_REST::decodeHttpResponse(对象(Google_Http_请求))#1 /var/www/html/public/pruebas_sociales/google-api/src/google/Client.php(512): Google_Http_REST::execute(对象(Google_客户端), 对象(Google_Http_请求))#2 /var/www/html/public/pruebas_sociales/google-api/src/google/Service/Resource.php(195): Google_客户端->执行(对象(Google_Http_请求))#3 /var/www/html/public/pruebas_sociales/google-api/src/google/Service/PlusDomains.php(491): 谷歌服务资源->调用('insert',数组,'Google服务…'))

4/var/www/html/public/pruebas_sociales/google api/examples/idtoken.php(114): 谷歌服务加上领域活动 /var/www/html/public/pruebas_sociales/google-api/src/google/Http/REST.php 在线79


两周前我就有这个问题了。我怎么能修好它?帮助。

您是否正在使用Google Apps帐户尝试此操作?您正在登录xxx@gmail.com作为电子邮件地址,域名API不适用于普通的GMail帐户。