Beginner - SleekXMPP - XEP-0060

1,279 views
Skip to first unread message

Sandro Munda

unread,
Feb 19, 2012, 11:41:24 AM2/19/12
to sleekxmpp-...@googlegroups.com
Hi all,

I'm playing with SleekXMPP. All is fine but I can't find the
documentation for the XEP-0060 (PubSub) plugin.
Are there some example snippets or something else ?

Thanks !

Sandro Munda
<munda....@gmail.com>

Stefan de Konink

unread,
Feb 19, 2012, 11:46:13 AM2/19/12
to sleekxmpp-...@googlegroups.com
On 19-02-12 17:41, Sandro Munda wrote:
> I'm playing with SleekXMPP. All is fine but I can't find the
> documentation for the XEP-0060 (PubSub) plugin.
> Are there some example snippets or something else ?

As client or as server?


Stefan

Sandro Munda

unread,
Feb 19, 2012, 11:47:18 AM2/19/12
to sleekxmpp-...@googlegroups.com
As a client.

Sandro Munda
<munda....@gmail.com>

Stefan de Konink

unread,
Feb 19, 2012, 11:52:44 AM2/19/12
to sleekxmpp-...@googlegroups.com
On 19-02-12 17:47, Sandro Munda wrote:
> As a client.

xmpp = sleekxmpp.ClientXMPP('your@full/jid', 'yourpass')
xmpp.registerPlugin('xep_0030') # Service Discovery
xmpp.registerPlugin('xep_0060') # PubSub
if xmpp.connect():
xmpp.process(threaded=True)
else:
sys.exit(1)

node = 'some node'

raw = xmpp.plugin["xep_0030"].get_items('disco.componentjid', node,
block=True)

str(raw['disco_items'])

raw = xmpp.plugin["xep_0060"].get_items('pubsub.componentjid', node,
block=True)

print str(raw['pubsub']['items'])

Does that help a bit?


Stefan

Sandro Munda

unread,
Feb 19, 2012, 12:03:27 PM2/19/12
to sleekxmpp-...@googlegroups.com


Thanks for your answer. I try to play with your snippet. But it's
strange that there's no more documentation. :-(

Lance Stout

unread,
Feb 19, 2012, 2:04:39 PM2/19/12
to sleekxmpp-...@googlegroups.com
Documentation for plugins is still in progress, but the main methods are documented in the source.

However, examples are always better, so here is a small pubsub client example. This still need some polish, but it will soon end up in the Sleek examples directory.

Usage:

# List available nodes
python pubsub_client.py -j your_jid -p yourpass pubsub.example.com nodes

# Create a new node, called 'node_name'
python pubsub_client.py -j your_jid -p yourpass pubsub.example.com create node_name

# Delete a node named 'node_name'
python pubsub_client.py -j your_jid -p yourpass pubsub.example.com delete node_name

# Purge all items from the node 'node_name'
python pubsub_client.py -j your_jid -p yourpass pubsub.example.com purge node_name

# Publish an item to a node 'node_name'
# NOTE: this will wrap 'someitemcontent' in a <test xmlns="test" /> wrapper.
python pubsub_client.py -j your_jid -p yourpass pubsub.example.com publish node_name someitemcontent

# Retrieve all items from the node 'node_name'
python pubsub_client.py -j your_jid -p yourpass pubsub.example.com get node_name

# Retrieve a single item from the node 'node_name' with id 'item_id'
python pubsub_client.py -j your_jid -p yourpass pubsub.example.com get node_name item_id

# Retract an item with id 'item_id' from node 'node_name'
python pubsub_client.py -j your_jid -p yourpass pubsub.example.com retract node_name item_id

# Subscribe to a node 'node_name'
python pubsub_client.py -j your_jid -p yourpass pubsub.example.com subscribe node_name

# Unsubscribe from the node 'node_name'
python pubsub_client.py -j your_jid -p yourpass pubsub.example.com unsubscribe node_name

You can run pubsub_events.py -j yourjid -p yourpass in a second terminal and watch the pubsub events come in as you play with the client.


-- Lance

pubsub_client.py
pubsub_events.py

Sandro Munda

unread,
Feb 19, 2012, 2:10:07 PM2/19/12
to sleekxmpp-...@googlegroups.com
Very useful ! Thanks a lots Lance !

Sandro Munda
<munda....@gmail.com>

Andrés More

unread,
Nov 20, 2013, 8:30:11 AM11/20/13
to sleekxmpp-...@googlegroups.com
Hi, I'm following the examples and I bumped into an issue while trying to play with the pubsub examples.
I can list nodes but when I try to create a node I see an auth error. I've checked that auth between those users are OK, so I don't understand what's missing.

<iq to="user02@localhost/41462715221384925528927795" from="user01@localhost" id="6e964381-8875-4771-b215-2f3a6037ac75-4" type="error"><error code="403" type="auth"><forbidden xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /></error><pubsub xmlns="http://jabber.org/protocol/pubsub"><create node="test" /></pubsub></iq>

Thanks!

Lance Stout

unread,
Nov 27, 2013, 12:14:32 AM11/27/13
to sleekxmpp-...@googlegroups.com

On Nov 20, 2013, at 8:30 AM, Andrés More <more....@gmail.com> wrote:

> Hi, I'm following the examples and I bumped into an issue while trying to play with the pubsub examples.
> I can list nodes but when I try to create a node I see an auth error. I've checked that auth between those users are OK, so I don't understand what's missing.

It looks like you’re trying to create a PubSub node on the JID user01@localhost as the user user02@localhost. Unless you’ve done some very special configuration on your server, that won’t work.

In this case you’re working with PEP nodes, which are pubsub nodes on bare user@host JIDs. Only that specific user is allowed to create nodes under that bare JID, but others may be allowed to view and subscribe them.

There are general pubsub components that your server may have a plugin for, which would allow anyone to create nodes, e.g. at pub sub.example.com.

— Lance
Reply all
Reply to author
Forward
0 new messages