#!/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.qcloud.com/v2/index.php"
#获取域名解析条目ID:recordId
action='RecordList'
src=printf "GETcns.api.qcloud.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"