Skip to content

PHP class for creating a session on server side to an XMPP server

License

Notifications You must be signed in to change notification settings

Cobrowser/xmpp-prebind-php

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XMPP Prebind for PHP

This class is for prebinding a XMPP Session with PHP.

Usage

  • Clone the repo
  • In your file where you want to do the prebinding:
/**
 * Comment here for explanation of the options.
 *
 * Create a new XMPP Object with the required params
 *
 * @param string $jabberHost Jabber Server Host
 * @param string $boshUri    Full URI to the http-bind
 * @param string $resource   Resource identifier
 * @param bool   $useSsl     Use SSL (not working yet, TODO)
 * @param bool   $debug      Enable debug
 */
$xmppPrebind = new XmppPrebind('your-jabber-host.tld', 'http://your-jabber-host/http-bind/', 'Your XMPP Clients resource name', false, false);
$xmppPrebind->connect($username, $password);
$xmppPrebind->auth();
$sessionInfo = $xmppPrebind->getSessionInfo(); // array containing sid, rid and jid
// // array containing relevant BOSH info i.e.
// {
//   wait: "60"
//   requests: "2"
//   ver: "1.8"
//   polling: "2"
//   inactivity: "10"
//   hold: ""
//   to: ""
//   ack: null
//   accept: ""
//   maxpause: "120"
// }
$boshInfo = $xmppPrebind->getBoshInfo(); 
  • If you use Candy, change the Candy.Core.Connect() line to the following:
Candy.Core.attach('<?php echo $sessionInfo['jid'] ?>', '<?php echo $sessionInfo['sid'] ?>', '<?php echo $sessionInfo['rid'] ?>');
  • You should now have a working prebinding with PHP

Debugging

If something doesn't work, you can enable Debug. Debug output is logged to FirePHP, so you have to install that first.

Other Languages

There exist other projects for other languages to support a prebind. Go googling :)

Be aware

This class is in no way feature complete. There may also be bugs. I'd appreciate it if you contribute or submit bug reports.

Thanks.

About

PHP class for creating a session on server side to an XMPP server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 99.8%
  • XML 0.2%