powered by Jive Software

How to send XMPP messages to the Java server using PHP

Hi,

I am in the middle of developing a community website and am looking at integrating the Jive Messenger for our messaging service and other services that we introduce.

Since the development is on PHP platform, I would like to know how would I send XMPP messages to the Jive Java Server using PHP and retrieve the online/offline/dnd, etc status from the server.

I have read through various threads that make use of a java plug in, but since our’'s is a PHP based platform I doubt that the plug in solution would work.

Can anyone please help?

Sunil

Hi Sunil,

Using PHP would not prevent you from using the presence plugin. Take a look at the url=http://www.jivesoftware.org/messenger/plugins/presence/readme.htmlread me[/url] for the plugin to see how you can make use of it.

Hope that helps,

Ryan

Hi Sunil,

on this homepage (http://cjphp.netflint.net/) you’'ll find a jabber class for PHP.

Finn

And, if all else fails, you could have a look at the PHP/Java integration (at http://www.php.net/manual/en/ref.java.php)

In addition to Guus, there is also the “PHP-Java-Bridge” project which is faster and also works with PHP 5.

http://php-java-bridge.sourceforge.net/

null

Install the presence-Plugin and then use this tiny function:

function jabber_online($jabber_user){

$handle = fopen(

http://127.0.0.1:9090/plugins/presence/status?jid=$jabber_user@jabber.mydomain.c om&type=xml9090/plugins/presence/status?jid=$jabber_user@jabber.mydomain.com&type=xml”,

“r”);

ob_start();

fpassthru($handle);

$xmlstr = ob_get_contents();

ob_end_clean();

$dom = domxml_open_mem($xmlstr);

$root = $dom->document_element();

$result = 1;

if ($root->has_attribute(’‘type’’)){

$result = 0;

}

return $result;

}[/code]

Cheers

JC