Hacker News new | ask | show | jobs
by nmjohn 3885 days ago
Nice - I've previously implemented this in (albeit far less extensible) a curl request, it's been working without hiccup for a while now as a cronjob

    CURRENT_IP=$(dig +short myip.opendns.com @resolver1.opendns.com)
    curl -X PUT 'https://api.cloudflare.com/client/v4/zones/'"$ZONE"'/dns_records/'"$DNS_RECORD_ID" \
      -H "Content-Type:application/json" \
      -H "X-Auth-Key:$AUTH_KEY" \
      -H "X-Auth-Email:$AUTH_EMAIL" \
      --data '{"zone_name":"'$ZONE_NAME'","zone_id":"'$ZONE'","type":"A","name":"'$ZONE_REC_NAME'","content":"'$CURRENT_IP'","data":{},"proxied":false,"proxiable":false,"ttl":1,"priority":1,"id":"'$DNS_RECORD_ID'","locked":false,"modified_on":"2015-08-26T03:10:40.975863Z","created_on":"2015-08-26T03:10:40.975863Z","meta":{"auto_added":false}}'
1 comments

Cool. I also did this using curl at first, before switching to php for more flexibility. It's not as neatly concise as yours, but I think its pretty similar: https://gist.github.com/lyoshenka/6257440