| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WebService::LiveJournal; |
|
2
|
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
821421
|
use strict; |
|
|
9
|
|
|
|
|
98
|
|
|
|
9
|
|
|
|
|
272
|
|
|
4
|
9
|
|
|
9
|
|
48
|
use warnings; |
|
|
9
|
|
|
|
|
19
|
|
|
|
9
|
|
|
|
|
208
|
|
|
5
|
9
|
|
|
9
|
|
129
|
use v5.10; |
|
|
9
|
|
|
|
|
29
|
|
|
6
|
9
|
|
|
9
|
|
94
|
use base qw( WebService::LiveJournal::Client ); |
|
|
9
|
|
|
|
|
38
|
|
|
|
9
|
|
|
|
|
5459
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ABSTRACT: (Deprecated) Interface to the LiveJournal API |
|
9
|
|
|
|
|
|
|
our $VERSION = '0.09'; # VERSION |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub _set_error |
|
12
|
|
|
|
|
|
|
{ |
|
13
|
0
|
|
|
0
|
|
|
my($self, $message) = @_; |
|
14
|
0
|
|
|
|
|
|
$self->SUPER::_set_error($message); |
|
15
|
0
|
|
|
|
|
|
die $message; |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
1; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
__END__ |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=pod |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=encoding UTF-8 |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 NAME |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
WebService::LiveJournal - (Deprecated) Interface to the LiveJournal API |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 VERSION |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
version 0.09 |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
new interface |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
use WebService::LiveJournal; |
|
39
|
|
|
|
|
|
|
my $client = WebService::LiveJournal->new( username => 'foo', password => 'bar' ); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
same thing with the old interface |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
use WebService::LiveJournal::Client; |
|
44
|
|
|
|
|
|
|
my $client = WebService::LiveJournal::Client->new( username => 'foo', password => 'bar' ); |
|
45
|
|
|
|
|
|
|
die "connection error: $WebService::LiveJournal::Client::error" unless defined $client; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
See L<WebService::LiveJournal::Event> for creating/updating LiveJournal events. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
See L<WebService::LiveJournal::Friend> for making queries about friends. |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
See L<WebService::LiveJournal::FriendGroup> for getting your friend groups. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
B<NOTE>: This distribution is deprecated. It uses the outmoded XML-RPC protocol. |
|
56
|
|
|
|
|
|
|
LiveJournal has also been compromised. I recommend using DreamWidth instead |
|
57
|
|
|
|
|
|
|
(L<https://www.dreamwidth.org/>) which is in keeping with the original philosophy |
|
58
|
|
|
|
|
|
|
LiveJournal regarding advertising. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
This is a client class for communicating with LiveJournal using its API. It is different |
|
61
|
|
|
|
|
|
|
from the other LJ modules on CPAN in that it originally used the XML-RPC API. It now |
|
62
|
|
|
|
|
|
|
uses a hybrid of the flat and XML-RPC API to avoid bugs in some LiveJournal deployments. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
There are two interfaces: |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=over 4 |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item L<WebService::LiveJournal> |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
The new interface, where methods throw an exception on error. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item L<WebService::LiveJournal::Client> |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
The legacy interface, where methods return undef on error and |
|
75
|
|
|
|
|
|
|
set $WebService::LiveJournal::Client::error |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=back |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
It is recommended that for any new code that you use the new interface. |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 new |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my $client = WebService::LiveJournal::Client->new( %options ) |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Connects to a LiveJournal server using the host and user information |
|
88
|
|
|
|
|
|
|
provided by C<%options>. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Signals an error depending on the interface |
|
91
|
|
|
|
|
|
|
selected by throwing an exception or returning undef. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head3 options |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=over 4 |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item server |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
The server hostname, defaults to www.livejournal.com |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item port |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
The server port, defaults to 80 |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item username [required] |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
The username to login as |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item password [required] |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
The password to login with |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item mode |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
One of either C<cookie> or C<challenge>, defaults to C<cookie>. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=back |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
These attributes are read-only. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 server |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
The name of the LiveJournal server |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 port |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
The port used to connect to LiveJournal with |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 username |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
The username used to connect to LiveJournal |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 userid |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
The LiveJournal userid of the user used to connect to LiveJournal. |
|
138
|
|
|
|
|
|
|
This is an integer. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 fullname |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
The fullname of the user used to connect to LiveJournal as LiveJournal understands it |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head2 usejournals |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
List of shared/news/community journals that the user has permission to post in. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 message |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Message that should be displayed to the end user, if present. |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 useragent |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Instance of L<LWP::UserAgent> used to connect to LiveJournal |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 cookie_jar |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Instance of L<HTTP::Cookies> used to connect to LiveJournal with |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head2 fastserver |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
True if you have a paid account and are entitled to use the |
|
163
|
|
|
|
|
|
|
fast server mode. |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 METHODS |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head2 create_event |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
$client->create_event( %options ) |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Creates a new event and returns it in the form of an instance of |
|
172
|
|
|
|
|
|
|
L<WebService::LiveJournal::Event>. This does not create the |
|
173
|
|
|
|
|
|
|
event on the LiveJournal server itself, until you use the |
|
174
|
|
|
|
|
|
|
C<update> methods on the event. |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
C<%options> contains a hash of attribute key, value pairs for |
|
177
|
|
|
|
|
|
|
the new L<WebService::LiveJournal::Event>. The only required |
|
178
|
|
|
|
|
|
|
attributes are C<subject> and C<event>, though you may set these |
|
179
|
|
|
|
|
|
|
values after the event is created as long as you set them |
|
180
|
|
|
|
|
|
|
before you try to C<update> the event. Thus this: |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
my $event = $client->create( |
|
183
|
|
|
|
|
|
|
subject => 'a new title', |
|
184
|
|
|
|
|
|
|
event => 'some content', |
|
185
|
|
|
|
|
|
|
); |
|
186
|
|
|
|
|
|
|
$event->update; |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
is equivalent to this: |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
my $event = $client->create; |
|
191
|
|
|
|
|
|
|
$event->subject('a new title'); |
|
192
|
|
|
|
|
|
|
$event->event('some content'); |
|
193
|
|
|
|
|
|
|
$event->update; |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
This method signals an error depending on the interface |
|
196
|
|
|
|
|
|
|
selected by throwing an exception or returning undef. |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head2 get_events |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
$client->get_events( $select_type, %query ) |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Selects events from the LiveJournal server. The actual C<%query> |
|
203
|
|
|
|
|
|
|
parameter requirements depend on the C<$select_type>. |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Returns an instance of L<WebService::LiveJournal::EventList>. |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Select types: |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=over 4 |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=item syncitems |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
This query mode can be used to sync all entries with multiple calls. |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=over 4 |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=item lastsync |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
The date of the last sync in the format of C<yyyy-mm-dd hh:mm:ss> |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=back |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=item day |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
This query can be used to fetch all the entries for a particular day. |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=over 4 |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=item year |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
4 digit integer |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=item month |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
1 or 2 digit integer, 1-31 |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=item day |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
integer 1-12 |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=back |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=item lastn |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
Fetch the last n events from the LiveJournal server. |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=over 4 |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=item howmany |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
integer, default = 20, max = 50 |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=item beforedate |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
date of the format C<yyyy-mm-dd hh:mm:ss> |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=back |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=back |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
This method signals an error depending on the interface |
|
262
|
|
|
|
|
|
|
selected by throwing an exception or returning undef. |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=head2 get_event |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
$client->get_event( $itemid ) |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
Given an C<itemid> (the internal LiveJournal identifier for an event). |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
This method signals an error depending on the interface |
|
271
|
|
|
|
|
|
|
selected by throwing an exception or returning undef. |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=head2 sync_items |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
$client->sync_items( $cb ) |
|
276
|
|
|
|
|
|
|
$client->sync_items( last_sync => $time, $cb ) |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
Fetch all of the items which have been created/modified since the last sync. |
|
279
|
|
|
|
|
|
|
If C<last_sync =E<gt> $time> is not provided then it will fetch all events. |
|
280
|
|
|
|
|
|
|
For each item that has been changed it will call the code reference C<$cb> |
|
281
|
|
|
|
|
|
|
with three arguments: |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
$cb->($action, $type, $id) |
|
284
|
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
=over 4 |
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
=item action |
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
One of C<create> or C<update> |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=item type |
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
For "events" (journal entries) this is C<L> |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=item id |
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
The internal LiveJournal server id for the item. An integer. |
|
298
|
|
|
|
|
|
|
For events, the actual event can be fetched using the C<get_event> |
|
299
|
|
|
|
|
|
|
method. |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
=back |
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
If the callback throws an exception, then no more entries will be processed. |
|
304
|
|
|
|
|
|
|
If the callback does not throw an exception, then the next item will be |
|
305
|
|
|
|
|
|
|
processed. |
|
306
|
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
This method returns the time of the last entry successfully processed, which |
|
308
|
|
|
|
|
|
|
can be passed into C<sync_item> the next time to only get the items that have |
|
309
|
|
|
|
|
|
|
changed since the first time. |
|
310
|
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
Here is a broad example: |
|
312
|
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
# first time: |
|
314
|
|
|
|
|
|
|
my $time = $client->sync_items(sub { |
|
315
|
|
|
|
|
|
|
my($action, $type, $id) = @_; |
|
316
|
|
|
|
|
|
|
if($type eq 'L') |
|
317
|
|
|
|
|
|
|
{ |
|
318
|
|
|
|
|
|
|
my $event = $client->get_item($id); |
|
319
|
|
|
|
|
|
|
# ... |
|
320
|
|
|
|
|
|
|
if(error condition) |
|
321
|
|
|
|
|
|
|
{ |
|
322
|
|
|
|
|
|
|
die 'error happened'; |
|
323
|
|
|
|
|
|
|
} |
|
324
|
|
|
|
|
|
|
} |
|
325
|
|
|
|
|
|
|
}); |
|
326
|
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
# if an error happened during the sync |
|
328
|
|
|
|
|
|
|
my $error = $client->error; |
|
329
|
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
# next time: |
|
331
|
|
|
|
|
|
|
$time = $client->sync_items(last_sync => $time, sub { |
|
332
|
|
|
|
|
|
|
... |
|
333
|
|
|
|
|
|
|
}); |
|
334
|
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
Because the C<syncitems> rpc that this method depends on |
|
336
|
|
|
|
|
|
|
can make several requests before it completes it can fail |
|
337
|
|
|
|
|
|
|
half way through. If this happens, you can restart where |
|
338
|
|
|
|
|
|
|
the last successful item was processed by passing the |
|
339
|
|
|
|
|
|
|
return value back into C<sync_items> again. You can tell |
|
340
|
|
|
|
|
|
|
that C<sync_item> completed without error because the |
|
341
|
|
|
|
|
|
|
C<$client-E<gt>error> accessor should return a false value. |
|
342
|
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
=head2 get_friends |
|
344
|
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
$client->get_friends( %options ) |
|
346
|
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
Returns friend information associated with the account with which you are logged in. |
|
348
|
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
=over 4 |
|
350
|
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
=item complete |
|
352
|
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
If true returns your friends, stalkers (users who have you as a friend) and friend groups |
|
354
|
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
# $friends is a WS::LJ::FriendList containing your friends |
|
356
|
|
|
|
|
|
|
# $friend_of is a WS::LJ::FriendList containing your stalkers |
|
357
|
|
|
|
|
|
|
# $groups is a WS::LJ::FriendGroupList containing your friend groups |
|
358
|
|
|
|
|
|
|
my($friends, $friend_of, $groups) = $client-E<gt>get_friends( complete => 1 ); |
|
359
|
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
If false (the default) only your friends will be returned |
|
361
|
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
# $friends is a WS::LJ::FriendList containing your friends |
|
363
|
|
|
|
|
|
|
my $friends = $client-E<gt>get_friends; |
|
364
|
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
=item friendlimit |
|
366
|
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
If set to a numeric value greater than zero, this mode will only return the number of results indicated. |
|
368
|
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
=back |
|
370
|
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
=head2 get_friends_of |
|
372
|
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
$client->get_friend_of( %options ) |
|
374
|
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
Returns the list of users that are a friend of the logged in account. |
|
376
|
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
Returns an instance of L<WebService::LiveJournal::FriendList>, a list of |
|
378
|
|
|
|
|
|
|
L<WebService::LiveJournal::Friend>. |
|
379
|
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
Options: |
|
381
|
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
=over 4 |
|
383
|
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
=item friendoflimit |
|
385
|
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
If set to a numeric value greater than zero, this mode will only return the number of results indicated |
|
387
|
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
=back |
|
389
|
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
=head2 get_friend_groups |
|
391
|
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
$client->get_friend_groups |
|
393
|
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
Returns your friend groups. This comes as an instance of |
|
395
|
|
|
|
|
|
|
L<WebService::LiveJournal::FriendGroupList> that contains |
|
396
|
|
|
|
|
|
|
zero or more instances of L<WebService::LiveJournal::FriendGroup>. |
|
397
|
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
=head2 get_user_tags |
|
399
|
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
$client->get_user_tags; |
|
401
|
|
|
|
|
|
|
$client->get_user_tags( $journal_name ); |
|
402
|
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
Fetch the tags associated with the given journal, or the users journal |
|
404
|
|
|
|
|
|
|
if not specified. This method returns a list of zero or more |
|
405
|
|
|
|
|
|
|
L<WebService::LiveJournal::Tag> objects. |
|
406
|
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
=head2 console_command |
|
408
|
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
$client->console_command( $command, @arguments ) |
|
410
|
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
Execute the given console command with the given arguments on the |
|
412
|
|
|
|
|
|
|
LiveJournal server. Returns the output as a list reference. |
|
413
|
|
|
|
|
|
|
Each element in the list represents a line out output and consists |
|
414
|
|
|
|
|
|
|
of a list reference containing the type of output and the text |
|
415
|
|
|
|
|
|
|
of the output. For example: |
|
416
|
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
my $ret = $client->console_command( 'print', 'hello world' ); |
|
418
|
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
returns: |
|
420
|
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
[ |
|
422
|
|
|
|
|
|
|
[ 'info', "Welcome to 'print'!" ], |
|
423
|
|
|
|
|
|
|
[ 'success', "hello world" ], |
|
424
|
|
|
|
|
|
|
] |
|
425
|
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
=head2 batch_console_commands |
|
427
|
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
$client->batch_console_commands( $command1, $callback); |
|
429
|
|
|
|
|
|
|
$client->batch_console_commands( $command1, $callback, [ $command2, $callback, [ ... ] ); |
|
430
|
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
Execute a list of commands on the LiveJournal server in one request. Each command is a list reference. Each callback |
|
432
|
|
|
|
|
|
|
associated with each command will be called with the results of that command (in the same format returned by |
|
433
|
|
|
|
|
|
|
C<console_command> mentioned above, except it is passed in as a list instead of a list reference). Example: |
|
434
|
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
$client->batch_console_commands( |
|
436
|
|
|
|
|
|
|
[ 'print', 'something to print' ], |
|
437
|
|
|
|
|
|
|
sub { |
|
438
|
|
|
|
|
|
|
my @output = @_; |
|
439
|
|
|
|
|
|
|
... |
|
440
|
|
|
|
|
|
|
}, |
|
441
|
|
|
|
|
|
|
[ 'print', 'something else to print' ], |
|
442
|
|
|
|
|
|
|
sub { |
|
443
|
|
|
|
|
|
|
my @output = @_; |
|
444
|
|
|
|
|
|
|
... |
|
445
|
|
|
|
|
|
|
}, |
|
446
|
|
|
|
|
|
|
); |
|
447
|
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
=head2 set_cookie |
|
449
|
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
$client->set_cookie( $key => $value ) |
|
451
|
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
This method allows you to set a cookie for the appropriate security and expiration information. |
|
453
|
|
|
|
|
|
|
You shouldn't need to call it directly, but is available here if necessary. |
|
454
|
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
=head2 send_request |
|
456
|
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
$client->send_request( $procname, @arguments ) |
|
458
|
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
Make a low level request to LiveJournal with the given |
|
460
|
|
|
|
|
|
|
C<$procname> (the rpc procedure name) and C<@arguments> |
|
461
|
|
|
|
|
|
|
(should be L<RPC::XML> types). |
|
462
|
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
On success returns the appropriate L<RPC::XML> type |
|
464
|
|
|
|
|
|
|
(usually RPC::XML::struct). |
|
465
|
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
This method signals an error depending on the interface |
|
467
|
|
|
|
|
|
|
selected by throwing an exception or returning undef. |
|
468
|
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
=head2 send_flat_request |
|
470
|
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
$client->send_flat_request( $procname, @arguments ) |
|
472
|
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
Sends a low level request to the LiveJournal server using the flat API, |
|
474
|
|
|
|
|
|
|
with the given C<$procname> (the rpc procedure name) and C<@arguments>. |
|
475
|
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
On success returns the appropriate response. |
|
477
|
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
This method signals an error depending on the interface |
|
479
|
|
|
|
|
|
|
selected by throwing an exception or returning undef. |
|
480
|
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
=head2 error |
|
482
|
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
$client->error |
|
484
|
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
Returns the last error. This just returns |
|
486
|
|
|
|
|
|
|
$WebService::LiveJournal::Client::error, so it |
|
487
|
|
|
|
|
|
|
is still a global, but is a slightly safer shortcut. |
|
488
|
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
my $event = $client->get_event($itemid) || die $client->error; |
|
490
|
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
It is still better to use the newer interface which throws |
|
492
|
|
|
|
|
|
|
an exception for any error. |
|
493
|
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
=head1 EXAMPLES |
|
495
|
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
These examples are included with the distribution in its 'example' directory. |
|
497
|
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
Here is a simple example of how you would login/authenticate with a |
|
499
|
|
|
|
|
|
|
LiveJournal server: |
|
500
|
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
use strict; |
|
502
|
|
|
|
|
|
|
use warnings; |
|
503
|
|
|
|
|
|
|
use WebService::LiveJournal; |
|
504
|
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
print "user: "; |
|
506
|
|
|
|
|
|
|
my $user = <STDIN>; |
|
507
|
|
|
|
|
|
|
chomp $user; |
|
508
|
|
|
|
|
|
|
print "pass: "; |
|
509
|
|
|
|
|
|
|
my $password = <STDIN>; |
|
510
|
|
|
|
|
|
|
chomp $password; |
|
511
|
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
my $client = WebService::LiveJournal->new( |
|
513
|
|
|
|
|
|
|
server => 'www.livejournal.com', |
|
514
|
|
|
|
|
|
|
username => $user, |
|
515
|
|
|
|
|
|
|
password => $password, |
|
516
|
|
|
|
|
|
|
); |
|
517
|
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
print "$client\n"; |
|
519
|
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
if($client->fastserver) |
|
521
|
|
|
|
|
|
|
{ |
|
522
|
|
|
|
|
|
|
print "fast server\n"; |
|
523
|
|
|
|
|
|
|
} |
|
524
|
|
|
|
|
|
|
else |
|
525
|
|
|
|
|
|
|
{ |
|
526
|
|
|
|
|
|
|
print "slow server\n"; |
|
527
|
|
|
|
|
|
|
} |
|
528
|
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
Here is a simple example showing how you can post an entry to your |
|
530
|
|
|
|
|
|
|
LiveJournal: |
|
531
|
|
|
|
|
|
|
|
|
532
|
|
|
|
|
|
|
use strict; |
|
533
|
|
|
|
|
|
|
use warnings; |
|
534
|
|
|
|
|
|
|
use WebService::LiveJournal; |
|
535
|
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
print "user: "; |
|
537
|
|
|
|
|
|
|
my $user = <STDIN>; |
|
538
|
|
|
|
|
|
|
chomp $user; |
|
539
|
|
|
|
|
|
|
print "pass: "; |
|
540
|
|
|
|
|
|
|
my $password = <STDIN>; |
|
541
|
|
|
|
|
|
|
chomp $password; |
|
542
|
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
my $client = WebService::LiveJournal->new( |
|
544
|
|
|
|
|
|
|
server => 'www.livejournal.com', |
|
545
|
|
|
|
|
|
|
username => $user, |
|
546
|
|
|
|
|
|
|
password => $password, |
|
547
|
|
|
|
|
|
|
); |
|
548
|
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
print "subject: "; |
|
550
|
|
|
|
|
|
|
my $subject = <STDIN>; |
|
551
|
|
|
|
|
|
|
chomp $subject; |
|
552
|
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
print "content: (^D or EOF when done)\n"; |
|
554
|
|
|
|
|
|
|
my @lines = <STDIN>; |
|
555
|
|
|
|
|
|
|
chomp @lines; |
|
556
|
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
my $event = $client->create( |
|
558
|
|
|
|
|
|
|
subject => $subject, |
|
559
|
|
|
|
|
|
|
event => join("\n", @lines), |
|
560
|
|
|
|
|
|
|
); |
|
561
|
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
$event->update; |
|
563
|
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
print "posted $event with $client\n"; |
|
565
|
|
|
|
|
|
|
print "itemid = ", $event->itemid, "\n"; |
|
566
|
|
|
|
|
|
|
print "url = ", $event->url, "\n"; |
|
567
|
|
|
|
|
|
|
print "anum = ", $event->anum, "\n"; |
|
568
|
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
Here is an example of a script that will remove all entries from a |
|
570
|
|
|
|
|
|
|
LiveJournal. Be very cautious before using this script, once the |
|
571
|
|
|
|
|
|
|
entries are removed they cannot be brought back from the dead: |
|
572
|
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
use strict; |
|
574
|
|
|
|
|
|
|
use warnings; |
|
575
|
|
|
|
|
|
|
use WebService::LiveJournal; |
|
576
|
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
print "WARNING WARNING WARNING\n"; |
|
578
|
|
|
|
|
|
|
print "this will remove all entries in your LiveJournal account\n"; |
|
579
|
|
|
|
|
|
|
print "this probably cannot be undone\n"; |
|
580
|
|
|
|
|
|
|
print "WARNING WARNING WARNING\n"; |
|
581
|
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
print "user: "; |
|
583
|
|
|
|
|
|
|
my $user = <STDIN>; |
|
584
|
|
|
|
|
|
|
chomp $user; |
|
585
|
|
|
|
|
|
|
print "pass: "; |
|
586
|
|
|
|
|
|
|
my $password = <STDIN>; |
|
587
|
|
|
|
|
|
|
chomp $password; |
|
588
|
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
my $client = WebService::LiveJournal->new( |
|
590
|
|
|
|
|
|
|
server => 'www.livejournal.com', |
|
591
|
|
|
|
|
|
|
username => $user, |
|
592
|
|
|
|
|
|
|
password => $password, |
|
593
|
|
|
|
|
|
|
); |
|
594
|
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
print "$client\n"; |
|
596
|
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
my $count = 0; |
|
598
|
|
|
|
|
|
|
while(1) |
|
599
|
|
|
|
|
|
|
{ |
|
600
|
|
|
|
|
|
|
my $event_list = $client->get_events('lastn', howmany => 50); |
|
601
|
|
|
|
|
|
|
last unless @{ $event_list } > 0; |
|
602
|
|
|
|
|
|
|
foreach my $event (@{ $event_list }) |
|
603
|
|
|
|
|
|
|
{ |
|
604
|
|
|
|
|
|
|
print "rm: ", $event->subject, "\n"; |
|
605
|
|
|
|
|
|
|
$event->delete; |
|
606
|
|
|
|
|
|
|
$count++; |
|
607
|
|
|
|
|
|
|
} |
|
608
|
|
|
|
|
|
|
} |
|
609
|
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
print "$count entries deleted\n"; |
|
611
|
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
Here is a really simple command line interface to the LiveJournal |
|
613
|
|
|
|
|
|
|
admin console. Obvious improvements like better parsing of the commands |
|
614
|
|
|
|
|
|
|
and not displaying the password are left as an exercise to the reader. |
|
615
|
|
|
|
|
|
|
|
|
616
|
|
|
|
|
|
|
use strict; |
|
617
|
|
|
|
|
|
|
use warnings; |
|
618
|
|
|
|
|
|
|
use WebService::LiveJournal; |
|
619
|
|
|
|
|
|
|
|
|
620
|
|
|
|
|
|
|
my $client = WebService::LiveJournal->new( |
|
621
|
|
|
|
|
|
|
server => 'www.livejournal.com', |
|
622
|
|
|
|
|
|
|
username => do { |
|
623
|
|
|
|
|
|
|
print "user: "; |
|
624
|
|
|
|
|
|
|
my $user = <STDIN>; |
|
625
|
|
|
|
|
|
|
chomp $user; |
|
626
|
|
|
|
|
|
|
$user; |
|
627
|
|
|
|
|
|
|
}, |
|
628
|
|
|
|
|
|
|
password => do { |
|
629
|
|
|
|
|
|
|
print "pass: "; |
|
630
|
|
|
|
|
|
|
my $pass = <STDIN>; |
|
631
|
|
|
|
|
|
|
chomp $pass; |
|
632
|
|
|
|
|
|
|
$pass; |
|
633
|
|
|
|
|
|
|
}, |
|
634
|
|
|
|
|
|
|
); |
|
635
|
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
while(1) |
|
637
|
|
|
|
|
|
|
{ |
|
638
|
|
|
|
|
|
|
print "> "; |
|
639
|
|
|
|
|
|
|
my $command = <STDIN>; |
|
640
|
|
|
|
|
|
|
unless(defined $command) |
|
641
|
|
|
|
|
|
|
{ |
|
642
|
|
|
|
|
|
|
print "\n"; |
|
643
|
|
|
|
|
|
|
last; |
|
644
|
|
|
|
|
|
|
} |
|
645
|
|
|
|
|
|
|
chomp $command; |
|
646
|
|
|
|
|
|
|
$client->batch_console_commands( |
|
647
|
|
|
|
|
|
|
[ split /\s+/, $command ], |
|
648
|
|
|
|
|
|
|
sub { |
|
649
|
|
|
|
|
|
|
foreach my $line (@_) |
|
650
|
|
|
|
|
|
|
{ |
|
651
|
|
|
|
|
|
|
my($type, $text) = @$line; |
|
652
|
|
|
|
|
|
|
printf "%8s : %s\n", $type, $text; |
|
653
|
|
|
|
|
|
|
} |
|
654
|
|
|
|
|
|
|
} |
|
655
|
|
|
|
|
|
|
); |
|
656
|
|
|
|
|
|
|
} |
|
657
|
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
=head1 HISTORY |
|
659
|
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
The code in this distribution was written many years ago to sync my website |
|
661
|
|
|
|
|
|
|
with my LiveJournal. It has some ugly warts and its interface was not well |
|
662
|
|
|
|
|
|
|
planned or thought out, it has many omissions and contains much that is apocryphal |
|
663
|
|
|
|
|
|
|
(or at least wildly inaccurate), but it (possibly) scores over the older |
|
664
|
|
|
|
|
|
|
LiveJournal modules on CPAN in that it has been used in production for |
|
665
|
|
|
|
|
|
|
many many years with very little maintenance required, and at the time of |
|
666
|
|
|
|
|
|
|
its original writing the documentation for those modules was sparse or misleading. |
|
667
|
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
669
|
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
=over 4 |
|
671
|
|
|
|
|
|
|
|
|
672
|
|
|
|
|
|
|
=item |
|
673
|
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
L<http://www.livejournal.com/doc/server/index.html>, |
|
675
|
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
=item |
|
677
|
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
L<Net::LiveJournal>, |
|
679
|
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
=item |
|
681
|
|
|
|
|
|
|
|
|
682
|
|
|
|
|
|
|
L<LJ::Simple> |
|
683
|
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
=back |
|
685
|
|
|
|
|
|
|
|
|
686
|
|
|
|
|
|
|
=head1 AUTHOR |
|
687
|
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
Graham Ollis <plicease@cpan.org> |
|
689
|
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
691
|
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
This software is copyright (c) 2013 by Graham Ollis. |
|
693
|
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
695
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
696
|
|
|
|
|
|
|
|
|
697
|
|
|
|
|
|
|
=cut |