Fearless O'Toole, Last British Columbian Pirate (kimera) wrote in lj_clients,
Fearless O'Toole, Last British Columbian Pirate

editevent stumped me...

I'm trying to write a script that will get eventid numbers from the RSS feed, delete all entries from the RSS page it downloads, then start the process again until no eventid numbers are found in the text. Despite the fact the script works, I keep getting the following error:

Client error: Can't edit post from requested journal

The code follows...

#!/usr/bin/perl -w

use strict;
use LWP;
use HTTP::Response;

my $browser = LWP::UserAgent->new();
my $url = "http://turbov21.livejournal.com/rss";
my $lj_url = "http://www.livejournal.com/interface/flat";
my $response;

while (1) {
        $response = $browser->get($url);
        unless ($response->is_success) { print "Could not get $url\n"; exit; }

        my @response = split (/\n/, $response->content);
        my $line;
        my $endit;

        foreach $line (@response) {
                if ($line =~ m/itemid=(.*)/) {
                        my $event = $1;
                        $event =~ s/<\/link\>//g;
                        $event =~ s/\n//g;
                        print "$event\n";
                        $endit = $event;

        unless ($endit) { exit; }

sub erase {
        my $itemid = $_[0];
        my $mode = "editevent";
        my $user = "turbov21";
        my $passwd = "password";
	my ($year, $mon, $day, $hour, $min) = &thetime;

        my $aresponse = $browser->post ( $lj_url,
                        'mode' => $mode,
                        'user' => $user,
                        'password' => $passwd,
                        'itemid' => $itemid,
                        'event' => "",
                        'subject' => "",
			'year' => $year,
			'mon' => $mon,
			'day' => $day,
			'hour' => $hour,
			'min' => $min,

        my $replied = $aresponse->content;
        print "$replied";

sub thetime {

	# this part is used to get the date and time of the entry.
	my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdat) = localtime(time);

	if ($min < 10) { $min = "0$min"; }
	if ($hour < 10) { $hour = "0$hour"; }
	if ($mday < 10) { $mday = "0$mday"; }
	$mon = $mon + 1;
	if ($mon < 10) { $mon = "0$mon"; }
	$year = $year + 1900;

	return($year, $mon, $mday, $hour, $min);

I hate to ask, but I've read and re-read the editevent documentation over and over, but can come up with nothing. Can someone tell me what I'm doing wrong or at least point me in the direction of something similar? Thanks!

  • 302: lj_dev

    In the interests of consolidating all LiveJournal development-related discussion, we're going to be closing down this community. The same…

  • Plain text to LJ

    I have an old blog from xanga that's in html/plain text and I want to move it over here. Which client would be the best to do this? I also want to…

  • ljKlient 0.2.0 Preview Release 1

    Today marks another milestone in the development of ljKlient — as the first preview of the 0.2 series is released.  Please go to the project…

  • Post a new comment


    Comments allowed for members only

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened