powered by Jive Software

Howto connect Parrot Botz plugin to a php-script?

Hi all,

I’ve been playing around for a few weeks with OpenFire and its plugins. Really cool.

I’ve succesfully setup my Plugin development environment and have been able to edit and build some plugins from source as well. Thanks to the well documented walkthroughs elsewhere on this site.

However I’m stuck at some Java scripting, which shouldn’t give to much problems for a experienced developer. I want to pass each received message from the Parrot Bot Plugin to a PHP-script, which will deal with it, after haver received it.

I’m currently using http://www.igniterealtime.org/community/docs/DOC-1130

at the following piece of code I want to , instead of echo the message/packet back to the sender, invoke a local php script and POST the received message:

public void processIncoming(Packet packet) {
                if (packet instanceof Message) {
                    // Echo back to sender
                    packet.setTo(packet.getFrom());
                    bot.sendPacket(packet);
                }
            }

I’ve been trying quiet some stuff such as URL.connect and so on, but I didn’t manage to succesfully create it.

Any real Java Programmer here who has the solution?

the php script is situated at localhost/index.php

looking forward to your thoughts!

all best, Roeland from Amsterdam

Hi,

not tried it, but HttpURLConnection looks good.

Edit: Ok, I think thats similar to URL class.

Other ideas:

  1. You can execute external scripts using ProcessBuilder:
ProcessBuilder pb = new ProcessBuilder("script", "argument");
Process p = pb.start();
p.waitFor();

Its possible to grap STDIN and STDOUT of the script.

  1. Reverse the work and let the PHP script do the request using an HTTP client written in PHP.

Message was edited by: Coolcat