开发者社区 > 域名解析DNS > 云解析DNS > 正文

如何用PHP调用DNS的API?

如何用PHP调用DNS的API?

展开
收起
请回答1024 2020-03-20 09:48:54 700 0
1 条回答
写回答
取消 提交回答
  • 使用PHP调用API示例

    本示例通过Alibaba Cloud SDK for PHP,完成添加解析记录(AddDomainRecord)的任务。

    use AlibabaCloud\Client\AlibabaCloud; use AlibabaCloud\Client\Exception\ClientException; use AlibabaCloud\Client\Exception\ServerException;

    // Download:https://github.com/aliyun/openapi-sdk-php // Usage:https://github.com/aliyun/openapi-sdk-php/blob/master/README.md

    AlibabaCloud::accessKeyClient(' ', ' ') ->regionId('cn-hangzhou') // replace regionId as you need ->asDefaultClient();

    try { $result = AlibabaCloud::rpc() ->product('Alidns') // ->scheme('https') // https | http ->version('2015-01-09') ->action('AddDomainRecord') ->method('POST') ->options([ 'query' => [ 'DomainName' => "dns-example.com", 'RR' => "apitest1", 'Type' => "A", 'Value' => "3.0.3.0", ], ]) ->request(); print_r($result->toArray()); } catch (ClientException $e) { echo $e->getErrorMessage() . PHP_EOL; } catch (ServerException $e) { echo $e->getErrorMessage() . PHP_EOL; }

    2020-03-20 09:49:14
    赞同 展开评论 打赏

阿里云云解析DNS产品相关资讯

相关产品

  • 云解析DNS
  • 相关电子书

    更多
    Spring Boot2.0实战Redis分布式缓存 立即下载
    CUDA MATH API 立即下载
    API PLAYBOOK 立即下载

    相关镜像