找回密码
 加入
搜索
楼主: kk_lee69

[网络通信] 如何使用AUTOIT 更新 GODADDY DNS? 有人可以协助改写吗??[已解決]

[复制链接]
发表于 2022-8-12 15:04:27 | 显示全部楼层
$httpObj.setRequestHeader('ContentType', 'application/json ' )
后面多了一个空格,单引号前
 楼主| 发表于 2022-8-12 15:23:07 | 显示全部楼层
zghwelcome 发表于 2022-8-12 15:03
把两边的中括号去了试试  [ ]

你說的這幾個 我都測試過了 就是失敗
发表于 2022-8-12 15:29:51 | 显示全部楼层
代码私我试试
 楼主| 发表于 2022-8-12 15:31:12 | 显示全部楼层

可以了 感謝  過了  將 ContentType  改為  Content-Type  就可以過了

感謝您的幫忙......................
 楼主| 发表于 2022-8-12 15:43:09 | 显示全部楼层
整理一下  回覆如下:

利用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

您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-12-22 10:44 , Processed in 0.089828 second(s), 14 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表