2
使用谷歌的PHP API客戶端的以下代碼我收到了這個響應。谷歌雲DNS服務 - entity.change參數是必需的,但缺少
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);
我對如何設置此參數有點困惑。或者我甚至可以定義它。
我想通了 - 經過6個小時的戰鬥 - 我意識到我需要將我的新增內容包裝在一個數組中。錯誤消息是神祕而無益的。 –
是拋出錯誤的rrdatas []數組? – user3547151
我需要將我的Google_Service_Dns_ResourceRecordSets包裝在一個數組中。我會盡快修改並回答。 –