[Perl]ATNDの参加者IDをTwitterでフォローする

Posted on 25th 2月 2010 in Perl, プログラム

30分ででっち上げたのでXMLのパースとかTwitterIDの正規表現とかいろいろ問題がありますが、何となく動いたので。
ATNDのID = TwitterのIDじゃないので誤フォローもありえます。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use strict;
use warnings;
use Net::Twitter;
use LWP::Simple;
use XML::Simple;
use URI::Escape;
 
# TwitterのID/PW
my $twitter = new Net::Twitter(
    username => 'username',
    password => 'password',
);
 
# ATNDのイベントID
my $event_id = 1;
 
my $uri = "http://api.atnd.org/events/users/?event_id=$event_id";
 
my $xml = LWP::Simple::get($uri) or die "cannot get content from $uri";
my $data = XML::Simple->new->XMLin($xml);
 
for (@{$data->{events}{event}{users}{user}}) {
    $twitter->create_friend(uri_escape_utf8 $_->{nickname}) if $_->{nickname} =~ /[A-Za-z0-9_]+/;
}
comments: 0 » tags: , このエントリをはてなブックマークに追加このエントリをdel.icio.usに追加このエントリをLivedoor Clipに追加このエントリをYahoo!ブックマークに追加

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

*

Comment

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>