2020-04-20 14:55:49
浏览数 (1)
前提条件
- 已经在qcloud上注册了域名,并随意定义了域名解析地址;
- 拥有云API秘钥,SecretId、SecretKey;
- 拥有可外网访问的IP地址;
- Linux可以访问外网。
获取解析记录
代码语言:javascript
复制#!/bin/bash
domain='你的域名,例如qq.com'
subDomain='你希望解析的子域名,例如wx.qq.com,则只输入wx'
sId='你的云API秘钥SecretId'
sKey='你的云API秘钥SecretKey'
signatureMethod='HmacSHA1'
timestamp=`date %s`
nonce=`head -200 /dev/urandom | cksum | cut -f2 -d" "`
region=bj
url="https://cns.api.zijiebao.com/v2/index.php"
#获取域名解析条目ID:recordId
action='RecordList'
src=`printf "GETcns.api.zijiebao.com/v2/index.php?Action=%s&Nonce=%s&Region=%s&SecretId=%s&SignatureMethod=%s&Timestamp=%s&domain=%s" $action $nonce $region $sId $signatureMethod $timestamp $domain`
#echo 'src: ' $src
signature=`echo -n $src|openssl dgst -sha1 -hmac $sKey -binary |base64`
#echo 'signature: ' $signature
params=`printf "Action=%s&domain=%s&Nonce=%s&Region=%s&SecretId=%s&Signature=%s&SignatureMethod=%s&Timestamp=%s" $action $domain $nonce $region $sId "$signature" $signatureMethod $timestamp `
#echo 'params: ' $params
curl -G -d "$params" --data-urlencode "Signature=$signature" "$url"