coolniikou (owner)

Revisions

gist: 182911 Download_button fork
public
Public Clone URL: git://gist.github.com/182911.git
Embed All Files: show embed
hateB2FriendFeed.pl #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/perl
use strict;
use warnings;
 
use Net::FriendFeed;
use URI;
use XML::Feed;
use Encode;
use DateTime::Format::W3CDTF;
use Time::HiRes qw(sleep);
use Config::Pit;
use Data::Dumper;
 
 
my $config = pit_get("room_friendfeed.com", require => {
"username" => "coolniikou",
"password" => "your remotekey on friendfeed.com API"
   });
my $room = 'nickname of room on FriendFeed';
my $hb_username = 'hatenaBookmark username';
my $root_api = 'http://b.hatena.ne.jp/'.$hb_username.'/rss?of=';
 
my $count = '0';
while ( $count < 110 ){
my $url = $root_api.20*$count;
my $feed = XML::Feed->parse( URI->new( $url ));
#warn Dumper($feed),"\n";
for my $item ( $feed->entries ){
my @comment;
my $title = $item->title;
my $link = $item->link;
my $date = DateTime::Format::W3CDTF->parse_datetime(
$item->{entry}->{dc}->{date});
push @comment, $date->strftime('%Y/%m/%d %H:%M:%S');
 
my $subject = $item->{entry}->{dc}->{subject};
if ( defined $subject ){
if ( ref( $subject ) eq "ARRAY" ){
foreach my $tag ( @{ $subject } ){
$tag = "#".$tag;
push @comment,$tag;
}
} else {
my $tag = "#".$item->{entry}->{dc}->{subject};
push @comment, $tag;
}
}
my $comment = join(" ",@comment);
ffpost($title, $link, $comment, $room);
# warn $comment,"\n";
}
$count++;
}
 
 
sub ffpost{
my($title, $link, $comment, $room) = @_;
my @images;
my ($imgN, $linkN) = '';
use Net::FriendFeed;
my $ftf_anon = Net::FriendFeed->new;
my $ftf = Net::FriendFeed->new( {
login => $config->{username},
remotekey => $config->{password}
} );
#$ftf->publish_message($txt);
$ftf->publish_link($title, $link, $comment,[@images ,[$imgN,$linkN]], $room, 'Net::FriendFeed');
sleep(15);
}