?

Log in

No account? Create an account
LJ::Simple - LiveJournal Client Discussions [entries|archive|friends|userinfo]
LiveJournal Client Discussions

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

LJ::Simple [Aug. 19th, 2002|05:54 pm]
LiveJournal Client Discussions

lj_clients

[simonb]
[mood |geekygeeky]
[music |Collected euphoric dance]

A little while ago I was looking for a nice and simple API from which I could throw things into LJ from perl. Whilst I found some stuff, I didn't really find an API I liked.

The result was me writing a module called LJ::Simple which provides a nice and simple interface to LJ. Right now all the API can do is:

  • Log into the server
  • Post a new journal entry
  • Delete a journal entry

The page for the module is here

The following example posts a simple message into the test LJ.

use LJ::Simple;

# Log into the server
my $lj = new LJ::Simple ({
        user    =>      "test",
        pass    =>      "test",
      });
(defined $lj)
  || die "$0: Failed to log into LiveJournal: $LJ::Simple::error\n";

# Prepare the event
my %Event=();

$lj->NewEntry(\%Event) ||
  die "$0: Failed to create new entry: $LJ::Simple::error\n";

# Put in the entry
my $entry=<<EOF;
A simple entry made using <tt>LJ::Simple</tt> version $LJ::Simple::VERSION
EOF
$lj->SetEntry(\%Event,$entry)
  || die "$0: Failed to set entry: $LJ::Simple::error\n";

# Say we are happy
$lj->SetMood(\%Event,"happy")
  || die "$0: Failed to set mood: $LJ::Simple::error\n";

# Don't allow comments
$lj->Setprop_nocomments(\%Event,1);

my ($item_id,$anum,$html_id)=$lj->PostEntry(\%Event);
(defined $item_id)
  || die "$0: Failed to post journal entry: $LJ::Simple::error\n";
linkReply