root/mixi/trunk/post_blog_to_mixi.pl

Revision 82, 1.0 kB (checked in by miya, 5 years ago)

test commit.

  • Property svn:executable set to
Line 
1 #!/usr/local/bin/perl
2
3 use strict;
4 use warnings;
5 use WWW::Mixi;
6 use Jcode;
7 use LWP::Simple;
8 use XML::RAI;
9 use Date::Parse;
10
11 my $id       = 'xxx@xxxxx';
12 my $password = 'xxxxx';
13 my $feed_url = 'xxxxx';
14
15 my $rai = XML::RAI->parse_string(get($feed_url));
16
17 open my $in, 'last_update' or die $!;
18 my $last_update = <$in>;
19 close($in);
20 chomp $last_update;
21
22 my $mixi = WWW::Mixi->new( $id, $password );
23 my $response = $mixi->login;
24
25 my $most_recent_time = 0;
26 foreach my $item ( @{$rai->items} ) {
27     my $time = str2time($item->created);
28
29     if($time > $last_update){
30         my $description = "€³€ÎÆüµ­€ÎÆâÍÆ€Ï¡¢³°Éô¥Ö¥í¥°€Ëœñ€«€ì€Æ€€€Þ€¹¡£\n"
31             . $item->link . "\n";
32        
33         my %diary = (
34                      diary_title => Jcode->new($item->title)->euc,
35                      diary_body  => $description,
36                      );
37
38         my $result = $mixi->get_add_diary_confirm(%diary);
39
40         if($time > $most_recent_time){
41             $most_recent_time = $time;
42         }
43     }
44 }
45
46 if($most_recent_time > $last_update){
47     open my $out, '> last_update' or die $!;
48     print $out $most_recent_time;
49     close($out);
50 }
51
52 exit;
Note: See TracBrowser for help on using the browser.