是否有人有一个工作的例子,如何更新网站所有权与谷歌API PHP SDK?
我可以连接到API,获取站点详细信息,我尝试了不同的方法来调用更新方法,但我甚至没有收到错误消息。
代码是这样的:
$service = new Google_Service_SiteVerification($client);
$siteList = $service->webResource->listWebResource();
$siteArray = array();
foreach ($siteList->getItems() as $siteItem)
{
array_push($siteArray, $siteItem);
}
$email_address = "new@email.address";
foreach ($siteArray as $site)
{
$owners = $site->getOwners();
array_push($owners, $email_address);
$site->setOwners($owners);
$reponse = $service->webResource->update($site->id, $site);
print_r($reponse);
}
好了,我找到答案了。解决方案是加urldecode:
$response = $service->webResource->update(urldecode($site->id), $site);