simple web page to control some http rest api functions

0

I have some hardware that exposes an http api (KEMP Load Balancers) (http://kemptechnologies.com/files/support/documentation/KEMP_Restful%20API.pdf)

I would like to create a web page that has some buttons that will operate the API.

For example, this is one of the things that API can do.

https://<LoadMasterIPAddress>/access/showrs?vs=<IPaddr>&port=<Port>&prot=<tcp/udp>&rs=<RS IPaddr>&rsport=<RS-Port> 

That returns some XML based data. I would like to display that somehow.

Another example would be to stop/start "real servers" behind the load balancer

https://<LoadMasterIPAddress>/access/enablers?rs=<IP-addr> 
or 
https://<LoadMasterIPAddress>/access/disablers?rs=<IP-addr>

I can do this with curl in a bash or powershell script but I really need it on a webpage that a customer/end user can use.

Can I do this with PHP? I really need some example code and I can run with it from there.

AaronJAnderson

Posted 2014-06-06T13:19:49.357

Reputation: 283

Question was closed 2014-06-06T15:03:58.693

Do you want the web page to run from a web server or from a client PC? Both are possible. – Julian Knight – 2014-06-06T13:31:50.480

Where the PHP file runs from is far less important to me than the code needed to make the page. It doesn't matter where. Assume there is already a running apache/php system running. – AaronJAnderson – 2014-06-06T13:35:36.397

I've not time to run up an example just now but I can say it is certainly possible. There are lots of options though. Do it all client side (the server only serves the page), do it all server side (PHP does everything in the background) or a hybrid. Hard to choose the best when you don't know the details. I do most stuff in JavaScript these days so I'd probably work client side. Using the JQuery library to make everything easier. Like parsing any return XML. – Julian Knight – 2014-06-06T13:44:47.203

I would need/like to parse return XML! – AaronJAnderson – 2014-06-06T14:35:28.737

JQuery has an XMLparse function as does PHP of course. The complexity of the question is really exceeding a sensible answer here I think. If nothing else, this needs to be moved to Stack Overflow. – Julian Knight – 2014-06-06T14:43:17.217

Answers

1

OK, so this is a rather simplistic answer and hopefully someone will do more for you.

You can simply embed the links into a web page:

<html>
  <head>
    <title>Server Controller</title>
  </head>
  <body>
    <p><a href="https://<LoadMasterIPAddress>/access/showrs?vs=<IPaddr>&port=<Port>&prot=tcp&rs=<RS IPaddr>&rsport=<RS-Port>">Show RS</a></p>
    <p><a href="https://<LoadMasterIPAddress>/access/enablers?rs=<IP-addr>">Stop Server 1</a></p>
  </body>
</html>

Clicking on the link will activate the API accordingly and any output should return to the browser. Of course, if the output is XML, it is likely to look horrible! You would need additional code to handle that and it gets a bit complicated. More so than I have time to do just now I'll see if I can find some time later if no one else has responded.

Julian Knight

Posted 2014-06-06T13:19:49.357

Reputation: 13 389

Might be a little too simple; For example, a single physical server might have 15 ip addresses on it; each IP is a real server, so to do one "task" I might have to click 15 different links. :/ – AaronJAnderson – 2014-06-06T14:38:08.390

;) Well it is a start, thanks for being kind! It wasn't clear from the Q that you needed to batch up tasks like that - so I'd agree that my answer is not brilliant! That is more complexity though. – Julian Knight – 2014-06-06T14:41:42.943