line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::WebService::Twitter::Util; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
58445
|
use strict; |
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
70
|
|
4
|
3
|
|
|
3
|
|
11
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
63
|
|
5
|
3
|
|
|
3
|
|
11
|
use Exporter 'import'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
87
|
|
6
|
3
|
|
|
3
|
|
496
|
use Mojo::URL; |
|
3
|
|
|
|
|
110622
|
|
|
3
|
|
|
|
|
41
|
|
7
|
3
|
|
|
3
|
|
406
|
use Time::Piece (); |
|
3
|
|
|
|
|
6373
|
|
|
3
|
|
|
|
|
503
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1.000'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw(parse_twitter_timestamp twitter_authorize_url); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $API_BASE_URL = 'https://api.twitter.com/1.1/'; |
14
|
|
|
|
|
|
|
our $OAUTH_BASE_URL = 'https://api.twitter.com/oauth/'; |
15
|
|
|
|
|
|
|
our $OAUTH2_BASE_URL = 'https://api.twitter.com/oauth2/'; |
16
|
|
|
|
|
|
|
|
17
|
44
|
|
|
44
|
1
|
160
|
sub parse_twitter_timestamp { Time::Piece->strptime(shift, '%a %b %d %H:%M:%S %z %Y') } |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
0
|
1
|
0
|
sub twitter_authorize_url { _oauth_url('authorize')->query(oauth_token => shift) } |
20
|
|
|
|
|
|
|
|
21
|
9
|
|
|
9
|
|
32
|
sub _api_url { Mojo::URL->new($API_BASE_URL)->path(shift) } |
22
|
2
|
|
|
2
|
|
12
|
sub _oauth_url { Mojo::URL->new($OAUTH_BASE_URL)->path(shift) } |
23
|
1
|
|
|
1
|
|
3
|
sub _oauth2_url { Mojo::URL->new($OAUTH2_BASE_URL)->path(shift) } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
1; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 NAME |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Mojo::WebService::Twitter::Util - Utility functions for Twitter client |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 SYNOPSIS |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
use Mojo::WebService::Twitter::Util 'parse_twitter_timestamp'; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $epoch = parse_twitter_timestamp('Fri Oct 23 17:18:19 +0100 2015')->epoch; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 DESCRIPTION |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
L contains utility functions used by |
40
|
|
|
|
|
|
|
L for interacting with the L |
41
|
|
|
|
|
|
|
API. All functions are exportable on demand. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 FUNCTIONS |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 parse_twitter_timestamp |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $time = parse_twitter_timestamp($ts); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Takes a timestamp string in the format returned by Twitter and returns a |
50
|
|
|
|
|
|
|
corresponding L object in UTC. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 twitter_authorize_url |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $url = twitter_authorize_url($token); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Takes an OAuth 1.0 request token and returns a L for manual user |
57
|
|
|
|
|
|
|
authorization. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 BUGS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Report any issues on the public bugtracker. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 AUTHOR |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Dan Book |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This software is Copyright (c) 2015 by Dan Book. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
This is free software, licensed under: |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 SEE ALSO |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
L |