【发布时间】:2015-08-04 17:38:09
【问题描述】:
我正在尝试解决一个谜 :) 我正在尝试通过命令行使用 php 脚本将属性 url 添加到我的 Google 搜索控制台。 该网站似乎添加正确,因为 IU 可以使用 list 方法列出它,但我无法找到它被添加到哪个帐户:(
这是我用来添加网站的代码
$client_email = '12345-blablablabla@developer.gserviceaccount.com';
$private_key = file_get_contents('mykey.p12');
$scopes = array('https://www.googleapis.com/auth/webmasters');
$credentials = new Google_Auth_AssertionCredentials(
$client_email,
$scopes,
$private_key
);
$client = new Google_Client();
$client->setAssertionCredentials($credentials);
if ($client->getAuth()->isAccessTokenExpired()) {
$client->getAuth()->refreshTokenWithAssertion();
}
$webmastersService = new Google_Service_Webmasters($client);
$webmastersService->sites->add($url);
如果我调用该方法 $webmastersService->sites->listSites()
我将返回我之前添加的属性。
但这是在哪个 google 帐户上添加的?这是一个谜:)
感谢您的帮助
【问题讨论】:
标签: php api google-search-console