how to call API in wordpress

neteater

Power Member
Joined
Feb 14, 2009
Messages
572
Reaction score
355
hi, i got an working API to do whois lookup for domain names, but the issue is i dont know how to use this api in wordpress, i tried on google but could not find easily understandable info, i am a webdesigner not a coder so could not understand too technicla things, any help is appricicated.
 
You need to know a little PHP and with the help of the WP's shortcode API, you can write a simple PHP function to parse the API data and display the results on your WP site.
 
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<meta charset="utf-8">
<title>Mashape Query</title>
<script>
function doIt() {
var output = $.ajax({
url: 'https://enclout-whois.p.mashape.com/show.json/', // The URL to the API. You can get this by clicking on "Show CURL example" from an API profile
type: 'GET POST', // The HTTP Method, can be GET POST PUT DELETE etc
data: {},g-zPXD8rmpHpdd8R6Hzb // Additional parameters here
datatype: 'json',
success: function(data) {
//
//Change data.source to data.something , where something is whichever part of the object you want returned.
//To see the whole object you can output it to your browser console using:
//console.log(data);
document.getElementById("output").innerHTML = data.source;
},
error: function(err) { alert(err); },
beforeSend: function(xhr) {
xhr.setRequestHeader("X-Mashape-Authorization", "KEyVvnBgaUmshNZLSpsJc64DuV0tp1csgh3jsnLylpMJLfQ3M4"); // Enter here your Mashape key
}
});


}

</script>
</head>
<body>

<button onclick="doIt()">Whois</button>
<div id="output">Result:</div>

</body>
</html>
 
Back
Top