整理一下 回覆如下:
利用AUTOIT 更新 GODADDY DNS 首先要去 GODADDY 申請API 才可以續續 後面
相關資訊 請參考 第一頁
簡單的改為AUTOIT 語法如下
$mydomain = "chain123.com"
$myhostname = "video"
$gdapikey = "KEY:密碼"
$url = "https://api.ipify.org"
$httpObj = ObjCreate("winhttp.winhttprequest.5.1")
$httpObj.open("GET", $url)
$httpObj.Send()
$HTMLSource = $httpObj.ResponseBody
ConsoleWrite(BinaryToString($HTMLSource)&@CRLF)
$NEWIP=BinaryToString($HTMLSource)
$url = "https://api.godaddy.com/v1/domains/" & $mydomain & "/records/A/" & $myhostname
$httpObj = ObjCreate("winhttp.winhttprequest.5.1")
$httpObj.open("GET", $url)
$httpObj.setRequestHeader('Authorization', 'sso-key ' & $gdapikey)
$httpObj.Send()
$HTMLSource = $httpObj.ResponseBody
ConsoleWrite(BinaryToString($HTMLSource) & @CRLF)
$OldIP=StringRegExpReplace(BinaryToString($HTMLSource), "[^\d]*(\d+.\d+.\d+.\d+).*", '$1')
ConsoleWrite($OldIP & @CRLF)
IF $NEWIP<>$OldIP Then
$url0='[{"data":"'&$NEWIP&'","name":"video","ttl":600,"type":"A"}]'
$url = "https://api.godaddy.com/v1/domains/" & $mydomain & "/records/A/" & $myhostname
$httpObj = ObjCreate("winhttp.winhttprequest.5.1")
$httpObj.open("PUT", $url)
$httpObj.setRequestHeader('Authorization', 'sso-key ' & $gdapikey)
$httpObj.setRequestHeader('Content-Type', 'application/json' )
;$httpObj.setRequestHeader('ContentType', 'text/xml' )
;$httpObj.setRequestHeader('Body', '[{"data":"211.2.2.2",}]' )
$httpObj.Send( $url0 )
$HTMLSource = $httpObj.ResponseBody
ConsoleWrite(BinaryToString($HTMLSource) & @CRLF)
EndIf
|