通过使用 Google 的 PHP API 客户端的以下代码,我收到了此响应。
Google_Service_Exception 带有消息“调用 POST 时出错https://www.googleapis.com/dns/v1/projects/PROJECT-NAME/managedZones/DNSZONE/changes : (400) 'entity.change' 参数是必需的,但缺少。
PROJECT-NAME 和 DNSZONE 是我的项目和区域。
$client_email = MYCLIENT;
$private_key = file_get_contents('config/credentials/KEY.p12');
$scopes = array('https://www.googleapis.com/auth/ndev.clouddns.readwrite');
$project = "PROJECT-NAME";
$managedZone = "DNSZONE";
$creds = new Google_Auth_AssertionCredentials($client_email,$scopes,$private_key);
$client = new Google_Client();
$client->setAssertionCredentials($creds);
$resource = new Google_Service_Dns_ResourceRecordSet();
$resource->kind = "dns#resourceRecordSet";
$resource->name = "testing.DNSZONE.net.";
$resource->rrdatas[] = "testing.otherhost.com.";
$resource->ttl = 800;
$resource->type = "CNAME";
$dns = new Google_Service_Dns($client);
$change = new Google_Service_Dns_Change();
$change->kind = "dns#change";
$change->setAdditions($resource);
$dns->changes->create($project,$managedZone,$change);
我对如何设置这个参数有点困惑。或者我什至在哪里来定义它。