line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::WebService::Twitter::User; |
2
|
2
|
|
|
2
|
|
15
|
use Mojo::Base -base; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
13
|
|
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
309
|
use Mojo::WebService::Twitter::Tweet; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
15
|
|
5
|
2
|
|
|
2
|
|
1055
|
use Mojo::WebService::Twitter::Util 'parse_twitter_timestamp'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
116
|
|
6
|
2
|
|
|
2
|
|
14
|
use Scalar::Util 'weaken'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
754
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.003'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has [qw(source created_at description followers friends id last_tweet name |
11
|
|
|
|
|
|
|
protected screen_name statuses time_zone url utc_offset verified)]; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub from_source { |
14
|
42
|
|
|
42
|
1
|
1998
|
my ($self, $source) = @_; |
15
|
42
|
100
|
|
|
|
141
|
$self->created_at(parse_twitter_timestamp($source->{created_at})) if defined $source->{created_at}; |
16
|
42
|
|
|
|
|
1553
|
$self->description($source->{description}); |
17
|
42
|
|
|
|
|
342
|
$self->followers($source->{followers_count}); |
18
|
42
|
|
|
|
|
297
|
$self->friends($source->{friends_count}); |
19
|
42
|
|
|
|
|
316
|
$self->id($source->{id}); |
20
|
42
|
|
|
|
|
277
|
$self->name($source->{name}); |
21
|
42
|
50
|
|
|
|
388
|
$self->protected($source->{protected} ? 1 : 0); |
22
|
42
|
|
|
|
|
441
|
$self->screen_name($source->{screen_name}); |
23
|
42
|
|
|
|
|
338
|
$self->statuses($source->{statuses_count}); |
24
|
42
|
|
|
|
|
304
|
$self->time_zone($source->{time_zone}); |
25
|
42
|
|
|
|
|
322
|
$self->url($source->{url}); |
26
|
42
|
|
|
|
|
283
|
$self->utc_offset($source->{utc_offset}); |
27
|
42
|
100
|
|
|
|
276
|
$self->verified($source->{verified} ? 1 : 0); |
28
|
42
|
100
|
|
|
|
397
|
if (defined $source->{status}) { |
29
|
2
|
|
|
|
|
10
|
my $tweet = Mojo::WebService::Twitter::Tweet->new->from_source($source->{status}); |
30
|
2
|
|
|
|
|
12
|
weaken($tweet->{user} = $self); |
31
|
2
|
|
|
|
|
8
|
$self->last_tweet($tweet); |
32
|
|
|
|
|
|
|
} |
33
|
42
|
|
|
|
|
129
|
$self->source($source); |
34
|
42
|
|
|
|
|
286
|
return $self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Mojo::WebService::Twitter::User - A Twitter user |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 SYNOPSIS |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
use Mojo::WebService::Twitter; |
46
|
|
|
|
|
|
|
my $twitter = Mojo::WebService::Twitter->new(api_key => $api_key, api_secret => $api_secret); |
47
|
|
|
|
|
|
|
my $user = $twitter->get_user(user_id => $user_id); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $username = $user->screen_name; |
50
|
|
|
|
|
|
|
my $name = $user->name; |
51
|
|
|
|
|
|
|
my $created_at = $user->created_at; |
52
|
|
|
|
|
|
|
my $description = $user->description; |
53
|
|
|
|
|
|
|
say "[$created_at] \@$username ($user): $description"; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 DESCRIPTION |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
L is an object representing a |
58
|
|
|
|
|
|
|
L user. See L |
59
|
|
|
|
|
|
|
for more information. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 source |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my $href = $user->source; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Source data hashref from Twitter API. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 created_at |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $ts = $user->created_at; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
L object representing the creation time of the user in UTC. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 description |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $description = $user->description; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
User's profile description. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 followers |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my $count = $user->followers; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Number of followers of the user. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 friends |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $count = $user->friends; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Number of friends of the user. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 id |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $user_id = $user->id; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
User identifier. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 last_tweet |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
my $tweet = $user->last_tweet; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Most recent tweet by the user (if any), as a L |
104
|
|
|
|
|
|
|
object. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 name |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
my $name = $user->name; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
User's full name. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head2 protected |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
my $bool = $user->protected; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Whether the user's tweets are protected. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 screen_name |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
my $screen_name = $user->screen_name; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
User's twitter screen name. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 statuses |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
my $count = $user->statuses; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Number of tweets the user has sent. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 time_zone |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
my $tz = $user->time_zone; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
String describing the user's time zone. This is now always undefined; see |
135
|
|
|
|
|
|
|
L. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 url |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
my $url = $user->url; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
User's profile URL. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 utc_offset |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
my $seconds = $user->utc_offset; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
User's current offset from UTC in seconds. This is now always undefined; see |
148
|
|
|
|
|
|
|
L. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 verified |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
my $bool = $user->verified; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Whether the user is a L. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 METHODS |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
L inherits all methods from L, and |
159
|
|
|
|
|
|
|
implements the following new ones. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 from_source |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
$user = $user->from_source($hr); |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Populate attributes from hashref of Twitter API source data. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 BUGS |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Report any issues on the public bugtracker. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 AUTHOR |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Dan Book |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
This software is Copyright (c) 2015 by Dan Book. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
This is free software, licensed under: |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 SEE ALSO |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
L |