| 1 | package WebService::SyncSBS::Delicious; | ||
| 2 | |||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | require Exporter; | ||
| 5 | |||
| 6 | our @ISA = qw(Exporter); | ||
| 7 | our $VERSION = '0.02'; | ||
| 8 | |||
| 9 | 0 | ▶ | use Net::Delicious; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 10 | |||
| 11 | sub new { | ||
| 12 | my $class = shift; | ||
| 13 | my $args = shift; | ||
| 14 | |||
| 15 | my $self = bless { | ||
| 16 | user => $args->{user}, | ||
| 17 | pass => $args->{pass}, | ||
| 18 | recent_num => $args->{recent_num}, | ||
| 19 | }, $class; | ||
| 20 | |||
| 21 | $self->{obj} = Net::Delicious->new({user => $self->{user}, pswd => $self->{pass}, debug => 0}); | ||
| 22 | |||
| 23 | return $self; | ||
| 24 | } | ||
| 25 | |||
| 26 | sub get_recent { | ||
| 27 | my $self = shift; | ||
| 28 | |||
| 29 | my $ret = {}; | ||
| 30 | foreach ($self->{obj}->recent_posts({count => $self->{recent_num}})) { | ||
| 31 | $ret->{$_->href} = { | ||
| 32 | url => $_->href, | ||
| 33 | title => $_->description, | ||
| 34 | description => $_->extended, | ||
| 35 | tags => $_->tags, | ||
| 36 | }; | ||
| 37 | |||
| 38 | utf8::decode($ret->{$_->href}->{url}); | ||
| 39 | utf8::decode($ret->{$_->href}->{title}); | ||
| 40 | utf8::decode($ret->{$_->href}->{description}); | ||
| 41 | utf8::decode($ret->{$_->href}->{tags}); | ||
| 42 | |||
| 43 | } | ||
| 44 | |||
| 45 | return $ret; | ||
| 46 | } | ||
| 47 | |||
| 48 | sub add { | ||
| 49 | my $self = shift; | ||
| 50 | my $obj = shift; | ||
| 51 | |||
| 52 | $self->{obj}->add_post({ | ||
| 53 | url => $obj->{url}, | ||
| 54 | description => $obj->{title}, | ||
| 55 | extended => $obj->{description}, | ||
| 56 | tags => $obj->{tags}, | ||
| 57 | dt => $obj->{issued}, | ||
| 58 | }); | ||
| 59 | } | ||
| 60 | |||
| 61 | sub delete { | ||
| 62 | my $self = shift; | ||
| 63 | } | ||
| 64 | |||
| 65 | 1; | ||
| 66 | __END__ | ||