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

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:

errmsg
Client error: Can't edit post from requested journal
success
FAIL


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";
                        &erase($event);
                        $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!
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

  • 5 comments