我没有使用过 Cloud DNS,但 API 似乎遵循与其他服务相同的格式,所以我将尝试让您了解它的工作原理。
PHP 库的文档不是最好的,但是查看源代码和注释您可以了解应该做什么。
我不确定您以前是否使用过该库,但第一步是创建和验证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);