Instant Messenger in PHP?
I am woking on another project, and need to be able to create an online inst开发者_StackOverflowant messenger that combines everybody's chat (Myspace, Facebook, Yahoo, AOL, Google , etc) into one in order to provide the user with an easy way to chat with all their friends and not have to download anything. I was thinking of doing this with PHP, but I'm not exactly sure how I would go about it. I have Googled this, but wasn't able to find any answers.
There are a number of things that you should start looking into here.
- XMPP is the protocol that most of these systems use. It stands for XML Presence Protocol, and is the format in which messages are sent.
Jabber, is an open source system that a lot of Chat clients are built on
JWChat is an open source, web-based system that seems to do roughly what you are looking for. http://blog.jwchat.org/jwchat/-
There is lots of information out there, so starting with a google search for XMPP I think you will find a wealth of information to start you on your project.
The Phurple project is somewhat incomplete, but as it builds on the Pidgin / libpurple core most of your requirements / messaging platforms are already supported, and you can just update libpurple using your package manager of choice to keep up-to-date on protocols. You do have to create deamon scripts to keep users logged in, it would not be advisable to try to keep connected in a webserver's process. A flow could simply be:
- User logs in
- Deamon process is spawned which logs in to users accounts.
- Further ajaxy requests from page connect to daemon process
- With a custom session handler you can easily destroy the daemon process on timeout of session.
On a side note: I would not want to be responsible for keeping logins & passwords to the users accounts. Make it your core concern that these are safe at all time
You'll probably want to use an existing IM library. Check out Telepathy and libpurple.
Unfortunately (or perhaps fortunately!) neither of these work directly with PHP (though it looks like there is a PHP DBUS library, which could be used to communicate with Telepathy). However, Telepathy does have a pre-made Python API; you might consider doing your app using Django or Pylons.
精彩评论