我在尝试从Google协作平台帐户(Google应用)阅读供稿。 我不需要我的应用程序来要求每个用户登录,因此我在“Google API控制台”中将我的ClientID创建为“服务帐户”。 我已将此客户ID和范围(https://sites.google.com/feeds/)添加到我的谷歌应用程序控制面板中的“Mange API客户端访问”页面。以“服务帐户”身份连接到Google Sites 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>";
我得到的回答是“无权访问该频道” 当我试图让这个饲料中的OAuth2.0的操场上记录使用我的谷歌Apps帐户我得到预期的响应。 我在这里俯瞰什么?