XMPP: how to post messages over HTTP
I have activated the http_message module which allows posting Jabber messages via HTTP.
The API is currently available at these addresses:
http://im.wordpress.org:5280/message
https://im.wordpress.org:5284/message
The ports may change; I’ll post here if that happens.
To use this API, you must send a Basic authenticated POST with an XMPP message element as the payload. Here is an example using curl:
$ curl 'http://im.wordpress.org:5280/message' -u 'andy@im.wordpress.org' --data-binary '<message to="andy@im.wordpress.com"><body>yo</body></message>' -i Enter host password for user 'andy@im.wordpress.org': HTTP/1.1 200 OK Content-Type: text/html; charset=utf-8 Content-Length: 3 OK
I recommend using XHTML-IM to format messages for clients that can render HTML. Example:
$ curl 'http://im.wordpress.org:5280/message' -u 'andy@im.wordpress.org' --data-binary '<message to="andy@im.wordpress.com" from="andy@im.wordpress.org"><body>yo!</body><html xmlns="http://jabber.org/protocol/xhtml-im"><body xmlns="http://www.w3.org/1999/xhtml"><em>yo!</em></body></html></message>'
If you want to send an identical message to multiple recipients, you can achieve this with one POST via the multicast address. We have a non-standard implementation of Extended Stanza Addressing that basically treats every address as a BCC. Multicast is only available to users who have been granted permission. Example:
$ curl 'https://im.wordpress.org:5284/message' -u 'andy@im.wordpress.org' --data-binary '<message to="multicast"><addresses><address jid="andy@im.wordpress.com"/><address jid="skeltoac@gmail.com"/></addresses><body>yo</body></message>'
This API also allows privileged users to forge the sender address. This is used on WordPress.com so that it looks like notifications come from a blog’s domain, even though XMPP services are not available on that domain. To use this feature, include the “from” attribute.
$ curl 'http://im.wordpress.org:5280/message' -u 'andy@im.wordpress.org' --data-binary '<message to="andy@im.wordpress.org" from="ticket-123@trac"><body>yo</body></message>'
Note that messages sent to a JID on a remote Jabber server (e.g. gtalk) won’t go through if the sender’s domain is changed. So if you want to forge the sender, you have to treat remote JIDs differently.
Any questions so far?
Alex M. 9:28 pm on July 21, 2010 Permalink
Sweet!
BTW: A couple of us are still having trouble connecting: http://wpdevel.wordpress.com/2010/07/16/xmpp/comment-page-1/#comment-8750
Mike Schinkel 3:53 am on July 22, 2010 Permalink
Any chance of front-ending the services with an HTML Form to make it obvious how to use it and easy to test without have to write code or get comfortable with curl?
Also, I sense this is really going to be significant but I can come up with any use-case examples; could you or others through out the things you envision people using this for?
Thanks in advance.
Alex M. 4:02 am on July 22, 2010 Permalink
For normal usage, you’d use a Jabber client, not this.
This post is more for the people who will be writing the plugins for Trac, the forums, etc. so that data can be sent to you via IM when a new ticket is made, etc. They need documentation on how to format their POST.
Mike Schinkel 4:08 am on July 22, 2010 Permalink
Thanks. As someone who typically does not use IM (because I don’t like the interruption), does this mean that a person would need to have an IM client open and active for this to be relevant? Is this not a general purpose notification system then, only for computer-to-person notification? If is merely for notification of people of actions that are happening on WordPress.org, or is it (potentially) broader than that?
Alex M. 4:09 am on July 22, 2010 Permalink
It’s like instant RSS sorta. I follow this blog via IM for example and got your comment as soon as it was posted.
Alex M. 4:11 am on July 22, 2010 Permalink
However yes, you can use it for person-to-person chats, but I don’t think many will be using it for that. IRC will still be the primary means of communication as it’s logged, everyone can participate, etc.
It’s just an easy way to keep track of what’s going on with the WordPress.org project all in one place and in realtime.
Mike Schinkel 4:47 am on July 22, 2010 Permalink
“person-to-person chats” – I was more interested in the opposite direction, i.e. as a notice to my website that could then run some code based on an event of interest.
Alex M. 4:55 am on July 22, 2010 Permalink
I think you’re confused, Mike. This is meant for features on WordPress.org (Trac, bbPress, etc.) to send messages to people via Jabber to let you know that events have occurred here on the site.
Mike Schinkel 5:02 am on July 22, 2010 Permalink
Yes, I probably am. But bear with me a bit; I do understand an HTTP POST is for sending a message, but what about a WebHook for receiving a message? Would it not be possible to apply a pubsub form model where the system could be used to notify subscribers via WebHook?
Alex M. 5:49 am on July 22, 2010 Permalink
Perhaps, but that doesn’t apply to this.
Harshad Joshi 7:00 am on October 8, 2010 Permalink
This code allows you to publish blog posts on wordpress using XMPP and XML-RPC => http://github.com/hj91/xmpp_to_wordpress
Its written in Python, someone might translate it to PHP..
Harshad Joshi 1:05 pm on October 8, 2010 Permalink
get a xmpp to wordpress blog posting bot – http://github.com/hj91/xmpp_to_wordpress
it basically takes incoming xmpp message and posts it on wordpress blog..needs xml-rpc to be actived.. my intention was to make it as a collaborative microblogging or federated microblogging..
ToDo – it should also be able to notify about comments.