我在谷歌开发人员控制台中设置了帐单和诸如此类的东西,并启用了Cloud DNS APi,然而它非常令人困惑,文档似乎带我在没有真正的例子的情况下绕圈子。
我想要一个关于如何使用Google Cloud DNS API的示例,该api使用来自Github的google-api-php-client脚本来添加DNS条目、删除DNS条目和更新DNS条目。
我也不确定我应该使用什么凭证,因为似乎没有任何方法来生成凭证--只有一个唯一的应用程序id (不能更改)用于这个计费服务。
他们的文档指出了stackoverflow中关于这个库使用的任何问题。
提前谢谢。
发布于 2014-11-03 09:29:47
我没有使用过Cloud DNS,但API似乎遵循与其他服务相同的格式,所以我将尝试让您了解它的工作原理。
PHP库的文档并不是最好的,但是通过查看source code和注释,您可以理解应该做什么。
我不确定您以前是否使用过这个库,但第一步是创建并验证Google_Client对象。在Github上有一些例子。
您可以在Developers Console创建凭据。选择项目,然后在侧边栏上选择APIs & auth / Credentials。
下面的代码显然只是一个草稿,请查阅库的源代码,看看所有可用的方法和选项。
<?php
// Assuming $client is a Google_Client instance that
// is already authenticated
$dns = new Google_Service_Dns($client);
$change = new Google_Service_Dns_Change();
$addition1 = new Google_Service_Dns_ResourceRecordSet();
// configure $addition1, check the methods on the lib
$deletion1 = new Google_Service_Dns_ResourceRecordSet();
// configure $deletion1, check the methods on the lib
$additions = array($addition1, ..., $additionN);
$deletions = array($deletion1, ..., $deletionN);
$change->setAdditions($additions);
$change->setDeletions($deletions);
// other settings on $change, check the lib
$dns->changes->create($project, $managedZone, $change);https://stackoverflow.com/questions/26262598
复制相似问题