Openfire website integration

Hi! I am trying to integrate Openfire into a website using the SparkWeb client. The website already had a friends system, but I thought rather than having two parallel friends systems I would adapt the website use the Openfire roster as its friends system - which I have stored in a MySQL database. I got the website to display existing friends correctly, what I’m not sure about is how to add new friends to the roster from the website.

I soon realised that it is a bad idea to just add new roster items into the database directly. To get round this problem I used the PHP Jabber client (http://code.blitzaffe.com/pages/phpclasses/files/jabber_client_52-11) to log in to the server and issue the friend request. I did get this somewhat working, but it is quite slow and too unreliable when called from the website in this way.

Is there a better way to initiate an Openfire friend request from a website? I was thinking perhaps I might be able to do it if I wrote an Openfire plugin, but I’m not quite sure how the plugin system works or whether this would be possible.

Thanks,

Ed.