Got http to update DDNS but can't figure scrip to do this.

I’ve finally get working script for DDNS on CloudFlare
It’s messy, but works :slight_smile:
Just put your token, id, domain

/system script
add name=CloudFlareDDNS policy=\
    ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api \
    source="#:log info (\"CloudFlare: 0\");\r\
    \n\r\
    \n# Define User Variables\r\
    \n:global CFusername \"yourmail@gmail.com\";\r\
    \n:global CFpassword \"cloudflaretoken\";\r\
    \n:global CFhost \"subdomain\";\r\
    \n:global CFhostid \"subdomainID\";\r\
    \n:global CFzone \"domain.com\";\r\
    \n#:log info (\"CloudFlare: 1\");\r\
    \n\r\
    \n# Define Global Variables\r\
    \n:global CFip;\r\
    \n:global CFlastip;\r\
    \n:if ([ :typeof \$CFlastip ] = nil ) do={ :global CFlastip \"0\" };\r\
    \n#:log info (\"CloudFlare: 2\");\r\
    \n\r\
    \n# Get the current IP\r\
    \n#   :log info \"CF: Performing remote IP detection.\"\r\
    \n   /tool fetch address=\"ip.changeip.com\" host=\"ip.changeip.com\" src-\
    path=(\"/\?\" . [/int eth get 0 mac-address ]) dst-path=\"ip.txt\" mode=ht\
    tp port=80\r\
    \n# Parse the IP address received from fetch script.\r\
    \n:delay 5s;\r\
    \n\t:local html [/file get \"ip.txt\" contents]\r\
    \n\t:local CFip [:pick \$html ([:find \$html \"<!--IPADDR=\"] + 11) [:find\
    \_\$html \"-->\"] ]\r\
    \n#   :log info \"CF: \$CFip\"\r\
    \n\r\
    \n# Is it a valid IP and is it different than the last one\?\r\
    \n\t:if ([:typeof [:toip \$CFip]] = \"ip\" AND \$CFip != \$CFlastip ) do={\
    \r\
    \n\t\t:log info \"CF: Sending UPDATE with \$CFip\"\r\
    \n#\t\t:log info (\"api_json.html\\\?tkn=\".\$CFpassword.\"&email=\".\$CFu\
    sername.\"&a=rec_edit&id=\".\$CFhostid.\"&z=\".\$CFzone.\"&type=A&name=\".\
    \$CFhost.\"&service_mode=0&ttl=120&content=\".\$CFip)\t\r\
    \n/tool fetch mode=https address=\"www.cloudflare.com\" src-path=(\"api_js\
    on.html\\\?tkn=\".\$CFpassword.\"&email=\".\$CFusername.\"&a=rec_edit&id=\
    \".\$CFhostid.\"&z=\".\$CFzone.\"&type=A&name=\".\$CFhost.\"&service_mode=\
    0&ttl=120&content=\".\$CFip) check-certificate=no dst-path=\"result.htm\" \
    host=www.cloudflare.com\r\
    \n\r\
    \n\t\t:global CFlastip \$CFip\r\
    \n\t} else={\r\
    \n#\t\t:log info \"CF: No update required.\"\r\
    \n\t}\r\
    \n"

to get id of subdomain you can use

https://www.cloudflare.com/api_json.html?a=rec_load_all&tkn=yourtoken&email=yourmail@gmail.com&z=domain.com