#!/usr/bin/perl -w use strict; use Jabber::Connection; use Jabber::NodeFactory; use Jabber::NS qw(:all); use Getopt::Long; use XML::Simple; use constant NS_PUBSUB => 'http://jabber.org/protocol/pubsub'; use constant NS_MOOD => 'http://jabber.org/protocol/mood'; my %optctl = (); &GetOptions(\%optctl, "value=s", "text=s"); my $config = XMLin(); my $nf = new Jabber::NodeFactory; # Open connection to Jabber server # -------------------------------- my $c = new Jabber::Connection( server => $config->{jabber}->{server}, log => 1, debug => 1, ); $c->connect or die "oops: ".$c->lastError; # Identify and authenticate with the server # ----------------------------------------- $c->auth($config->{jabber}->{username}, $config->{jabber}->{password}, $config->{jabber}->{resource}); my $node = $nf->newNode('iq'); $node->attr('type', 'set'); $node->attr('to', $config->{pubsub}->{host}); my $pubsub = $node->insertTag('pubsub', NS_PUBSUB); my $publish = $pubsub->insertTag('publish'); $publish->attr('node', $config->{pubsub}->{node}); my $item = $publish->insertTag('item'); $item->attr('id', 'current'); my $mood = $item->insertTag('mood', NS_MOOD); $mood->insertTag($optctl{value}); $mood->insertTag('text')->data($optctl{text}); $c->send($node); $c->process(3);