Simes (simonb) wrote in lj_clients,
Simes
simonb
lj_clients

  • Mood:
  • Music:

LJ::Simple

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";
Subscribe
  • Post a new comment

    Error

    Comments allowed for members only

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 0 comments