Wednesday, April 2, 2008

Introducing XMPPHP

Well, I've finally done it. I finally took two evenings and wrote a replacement to Class.Jabber.PHP that I had been promising for eons. It'll work with XMPP 1.0 servers, it does TLS, has persistent connections, is event driven, etc. I'll try to get some more documentation in the coming days, but the examples included give you a pretty good idea. Check it out at svn://netflint.net/xmpphp and http://code.google.com/p/xmpphp.

This is based largely on my experience building SleekXMPP, and I'll certainly be taking some things and applying it there (threadless mode, and simpler handlers).

The only thing missing from Class.Jabber.PHP is Rosters and Registration, which I'll get to in the coming days. Please take a look and provide any feedback you might have. Also feel free to ask for my help in implementing it. I'm off to bed!

21 comments:

11D.Universe said...

Hi. I tried implementing your code examples. I'm getting:

Parse error: syntax error, unexpected T_OBJECT_OPERATOR in xmpp.php on line 53

Skinner said...

Two minutes ago I was thinking of building an AJAX chat interface for a CMS. Then I thought it would be cool if when I was on Google Talk, clients in the CMS would be able to chat with me in real-time so I could help them out.

Google Talk must support an open service - XMPP - Great! Now to remember everything I forgot about the Sockets API...

No, wait, Fritzy the Great has already thought this one through!

This is an awesome piece of work - keep it up!

CloCkWeRX said...

Nice work! I look forward to seeing this evolve (more examples, more tests, more delicious goodness).

If you were keen, you could put this in as a PEAR proposal...

CloCkWeRX said...

See also:
PEAR::Log

Ashutosh said...

Hi nathan,
thanks for the great stuff you have bought out. it doesnt run in my setup though with some cli php notice and warnings. i used r18. Though i appied the patches listed in issue2, and 6, it still doesnt work. Please bring out a new revision soon

cheers!
ashu

chakri said...

grt8 work !! :)

Dan Phiffer said...

I'm curious, could XMPPHP be used to subscribe to the Twitter public feed? They are using PubSub (XEP-0060) which, from what I gather, is a plugin for XMPP. Is that the same kind of plugin listed on your TODO list in the README file?

Paris said...

Hi Fritzy,

What I can't seem to fully understand is how you can keep a session open through a Web Application which closes the connection upon PHP execution finishes...

anup Singh said...

Hi, My question is , How to connect to yahoo messenger, using XMPPHP? if any one can help me it would be great.
Thanks in advance.

Sebastian said...

your lib is great! Please keep on working on it, especially the MUC support ;-)

vad said...

Hi, nobody knows how to keep the connection up between ajax calls? (same thing paris wants to do, i think)

I tried to serialize the XMPP object, but it doesn't work.

Thank you

development said...

We'd like to implement the Roster and other functionality from code we've developed from xmpp for an automated transport client / bot.

How is best to join the project and help keep things moving?

Thanks

Roba said...

I've implemented your class and I noticed that it takes a realllly long time to run the example you provide on google code(loop bit, last example)...it works flawlessly but takes like 20 seconds....is that normal?

spsneo said...

Hello !
great work.
I have a problem.
I am in a university and I connect to web by http proxy server. But with proxy server XMPPHP doesnt work.
it gives this error:
Warning: stream_socket_client() [function.stream-socket-client]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/xmpphp/xmlstream.php on line 86

Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to tcp://talk.google.com:5222 (Unknown error) in /var/www/xmpphp/xmlstream.php on line 86
ERROR : Could not connect.
Warning: stream_set_blocking(): supplied argument is not a valid stream resource in /var/www/xmpphp/xmlstream.php on line 91


CAn you please help me out

HBR said...

Hi. I don't know where you have been up to with this class but it really rocks, and I must say, I am impatiently waiting for the Roster support.
The dev of my website is in stand by just because there are no classes out there dealing with xmpp, and I have no idea how to start my own API, I don't have the time neither to learn it from scratch.

So please, don't leave us hanging on ;)

olli said...

Good work! Here are however some suggestions to make usage of XMPPHP easier:

1) Making the function docblocks more verbose. This way the developer could treat the functionality as a set of black boxes instead of having to read and understand the implementation details.

2) Further hiding implementation by making XMLStream's functions protected or private where possible. This way the developer could clearly perceive the intended public interface.

Harish said...

I tried your code... but i didn't get any reactions...no alerts or nothing... can u please help me out... because am so much interested on open source programs. Also am opensource researcher.

I am a representer of Closedlogics community. Please explain me more detail.

You can contact me through : r.harishnarayanan@gmail.com

Thanks in advance

Harishankaran said...

Hi, I am using your library. I need to send a message to all the contacts (whether they are offline or online). The send message function is great, but how do I get the list of all the contacts?. Do you have any function for that?

Fabio said...

any of you guys know of a free web hosting who has a php version capable of running xmpphp? :)

Laurent J.V. Dubois Solu-Vente.com said...

Thanks for this contribution !

Bryon said...

Hello I was pointed here from the Jabber board. I am trying to have a button on out rep login page that will auto send a message with "one click". We are trying to get it to auto populate the to and message fields and auto send. We would like it not leave an open chat window just autosend one message stating "Need Assistance Station [A] --- where [A] is station number. We are using QueueMetrics and it will populate the [A] variable.