-
-
Save fcenobi/4477a8a96e1b3ad406470c65ec58afa2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <meta name="author" content="HKLCF"> | |
| <title>Cloudflare API (List zones)</title> | |
| </head> | |
| <body> | |
| <div id="result"></div> | |
| <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> | |
| <script> | |
| cors_proxy = "https://cors-anywhere.herokuapp.com/"; // CORS bypass | |
| email = ""; // your cloudflare login email | |
| auth_key = ""; // your auth key <https://www.cloudflare.com/a/account/my-account> | |
| $.ajax({ | |
| url: cors_proxy + "https://api.cloudflare.com/client/v4/zones", | |
| type: "GET", | |
| beforeSend: function(xhr) { | |
| xhr.setRequestHeader("X-Auth-Email", email); | |
| xhr.setRequestHeader("X-Auth-Key", auth_key); | |
| }, | |
| data: { | |
| }, | |
| dataType: "json", | |
| success: function(data) { | |
| if(data.result[0]) { | |
| $(data.result).each(function(){ | |
| $("#result").append("ID: "); | |
| $("#result").append(this.id); // get domain id | |
| $("#result").append("<br>"); | |
| $("#result").append("Domain: "); | |
| $("#result").append(this.name); // get domain name | |
| $("#result").append("<br>"); | |
| }); | |
| } else { | |
| $("#result").append("Domain not find"); | |
| } | |
| }, | |
| error: function() { | |
| $("#result").append("Login Error"); | |
| } | |
| }); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment