client = new JAXL(array( 'jid' => $config['JABBER_JID'], 'pass' => $config['JABBER_PASSWORD'], )); $this->client->require_xep([ '0060' // Publish-Subscribe ]); } } protected function _publish(string $text): void { $this->text = $text; $this->client->add_cb('on_auth_success', function() { $this->on_auth_success_callback(); }); $client->add_cb('on_auth_failure', function() { $this->on_auth_failure_callback(); }); $this->client->start(); } protected function on_auth_success_callback() { // create node // $client->xeps['0060']->create_node('pubsub.localhost', 'dummy_node'); // publish $item = new JAXLXml('item', null, array('id' => time())); $item->c('entry', 'http://www.w3.org/2005/Atom'); $item->c('title')->t('Soliloquy')->up(); $item->c('summary')->t($this->text)->up(); $item->c( 'link', null, array('rel' => 'alternate', 'type' => 'text/html', 'href' => 'http://denmark.lit/2003/12/13/atom03') )->up(); $item->c('published')->t('2003-12-13T18:30:02Z')->up(); $item->c('updated')->t('2003-12-13T18:30:02Z')->up(); $this->client->xeps['0060']->publish_item('pubsub.localhost', 'dummy_node', $item); } protected function on_auth_failure_callback($reason) { $this->client->send_end_stream(); } }