Php 连接到谷歌网站API作为一个;服务帐户“;

Php 连接到谷歌网站API作为一个;服务帐户“;,php,google-api,oauth-2.0,google-sites,google-oauth,Php,Google Api,Oauth 2.0,Google Sites,Google Oauth,我正在尝试从谷歌网站帐户(谷歌应用程序)读取提要。 我不需要我的应用程序要求每个用户都登录,所以我在“谷歌API控制台”中将我的ClientID创建为“服务帐户”。 我已经添加了这个客户端ID和作用域(https://sites.google.com/feeds/)转到我的谷歌应用程序控制面板中的“管理API客户端访问”页面 我使用下面的代码连接,所有常量都在我的代码中用正确的值定义 // api dependencies require_once(GOOGLE_API_PATH); // c

我正在尝试从谷歌网站帐户(谷歌应用程序)读取提要。 我不需要我的应用程序要求每个用户都登录,所以我在“谷歌API控制台”中将我的ClientID创建为“服务帐户”。 我已经添加了这个客户端ID和作用域(https://sites.google.com/feeds/)转到我的谷歌应用程序控制面板中的“管理API客户端访问”页面

我使用下面的代码连接,所有常量都在我的代码中用正确的值定义

// api dependencies
require_once(GOOGLE_API_PATH);

// create client object and set app name
$client = new Google_Client();
$client->setApplicationName(GOOGLE_API_NAME);

// set assertion credentials
$client->setAssertionCredentials(

new Google_AssertionCredentials(

GOOGLE_API_EMAIL,
array(GOOGLE_API_SCOPE),
file_get_contents(GOOGLE_API_PK) 
));

$client->setClientId(GOOGLE_API_CLIENTID);

// create service

$req = new Google_HttpRequest("https://sites.google.com/feeds/content/<herismydomainname.com>/intranet");
$val = $client->getIo()->authenticatedRequest($req);

// The contacts api only returns XML responses.
$response = json_encode($val->getResponseBody());
print "<pre>" . print_r(json_decode($response, true), true) . "</pre>";
//api依赖项
需要一次(谷歌API路径);
//创建客户端对象并设置应用程序名称
$client=新的Google_客户端();
$client->setApplicationName(GOOGLE\u API\u NAME);
//设置断言凭据
$client->setAssertionCredentials(
新Google_断言定义(
谷歌API电子邮件,
阵列(谷歌API范围),
文件获取内容(谷歌API PK)
));
$client->setClientId(GOOGLE\u API\u CLIENTID);
//创建服务
$req=新的Google\u HttpRequest(“https://sites.google.com/feeds/content//intranet");
$val=$client->getIo()->authenticatedRequest($req);
//contacts api仅返回XML响应。
$response=json_encode($val->getResponseBody());
打印“”。打印(json解码($response,true),true)。"";
我得到的答复是“未授权访问此提要” 当我尝试在OAuth2.0游乐场中使用我的google apps帐户登录时,我得到了预期的响应。
我在这里忽略了什么?

服务帐户和谷歌网站目前不能一起使用。Google Apps提供了一个消费者秘密,可以通过OAuth 1.0a中的双腿OAuth跨域访问数据


查看如何配置您的应用程序帐户,以及位于的示例代码。

我正在寻找一种读取Google站点帐户订阅源的方法,只需了解这是否找到了解决方案。