Google Cloud DNS Services - entity.change参数是必需的,但缺少 [英] Google Cloud DNS Services - entity.change parameter is required but missing

查看:229
本文介绍了Google Cloud DNS Services - 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);

对于如何设置此参数,我有点困惑。或者我甚至要定义它。

解决方案

只是为了澄清答案是什么,setAdditions期望一个数组。 p>

  $ change-> setAdditions([$ resource]); 


With the following code using Google's PHP API Client I am receiving this response.

Google_Service_Exception with message 'Error calling POST https://www.googleapis.com/dns/v1/projects/PROJECT-NAME/managedZones/DNSZONE/changes: (400) The 'entity.change' parameter is required but was missing.

Where PROJECT-NAME and DNSZONE are my project and zone.

$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);

I am a bit confused as to how to set this parameter. Or where I am even am to define it.

解决方案

Just for clarify what the answer is, setAdditions expects an array.

$change->setAdditions([ $resource ]);

这篇关于Google Cloud DNS Services - entity.change参数是必需的,但缺少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆