line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::WebService::Twitter::User; |
2
|
2
|
|
|
2
|
|
10
|
use Mojo::Base -base; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
9
|
|
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
196
|
use Mojo::WebService::Twitter::Tweet; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
10
|
|
5
|
2
|
|
|
2
|
|
694
|
use Mojo::WebService::Twitter::Util 'parse_twitter_timestamp'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
94
|
|
6
|
2
|
|
|
2
|
|
10
|
use Scalar::Util 'weaken'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
474
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.000'; |
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
|
22
|
|
|
22
|
1
|
1309
|
my ($self, $source) = @_; |
15
|
22
|
50
|
|
|
|
61
|
$self->created_at(parse_twitter_timestamp($source->{created_at})) if defined $source->{created_at}; |
16
|
22
|
|
|
|
|
997
|
$self->description($source->{description}); |
17
|
22
|
|
|
|
|
112
|
$self->followers($source->{followers_count}); |
18
|
22
|
|
|
|
|
100
|
$self->friends($source->{friends_count}); |
19
|
22
|
|
|
|
|
102
|
$self->id($source->{id}); |
20
|
22
|
|
|
|
|
103
|
$self->name($source->{name}); |
21
|
22
|
50
|
|
|
|
167
|
$self->protected($source->{protected} ? 1 : 0); |
22
|
22
|
|
|
|
|
221
|
$self->screen_name($source->{screen_name}); |
23
|
22
|
|
|
|
|
115
|
$self->statuses($source->{statuses_count}); |
24
|
22
|
|
|
|
|
101
|
$self->time_zone($source->{time_zone}); |
25
|
22
|
|
|
|
|
101
|
$self->url($source->{url}); |
26
|
22
|
|
|
|
|
99
|
$self->utc_offset($source->{utc_offset}); |
27
|
22
|
100
|
|
|
|
92
|
$self->verified($source->{verified} ? 1 : 0); |
28
|
22
|
100
|
|
|
|
192
|
if (defined $source->{status}) { |
29
|
2
|
|
|
|
|
6
|
my $tweet = Mojo::WebService::Twitter::Tweet->new->from_source($source->{status}); |
30
|
2
|
|
|
|
|
9
|
weaken($tweet->{user} = $self); |
31
|
2
|
|
|
|
|
5
|
$self->last_tweet($tweet); |
32
|
|
|
|
|
|
|
} |
33
|
22
|
|
|
|
|
56
|
$self->source($source); |
34
|
22
|
|
|
|
|
112
|
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 |