1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

how to call API in wordpress

Discussion in 'Blogging' started by neteater, Mar 18, 2015.

  1. neteater

    neteater Jr. VIP Jr. VIP

    Joined:
    Feb 14, 2009
    Messages:
    566
    Likes Received:
    335
    Location:
    somewhere between CPU an d heat sink
    Home Page:
    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.
     
  2. aldragon

    aldragon Power Member

    Joined:
    Aug 5, 2010
    Messages:
    719
    Likes Received:
    202
    Location:
    ^^
    http get post methods
     
  3. FBGuru

    FBGuru Senior Member

    Joined:
    Sep 22, 2013
    Messages:
    928
    Likes Received:
    1,172
    Location:
    Personality Type : ESTP
    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.
     
  4. neteater

    neteater Jr. VIP Jr. VIP

    Joined:
    Feb 14, 2009
    Messages:
    566
    Likes Received:
    335
    Location:
    somewhere between CPU an d heat sink
    Home Page:
  5. neteater

    neteater Jr. VIP Jr. VIP

    Joined:
    Feb 14, 2009
    Messages:
    566
    Likes Received:
    335
    Location:
    somewhere between CPU an d heat sink
    Home Page:
    <!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>