| 1 | package Mojo::WebService::Twitter::Util; | ||
| 2 | |||
| 3 | 3 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 3 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 3 | ▶ | use Exporter 'import'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 3 | ▶ | use Mojo::URL; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 3 | ▶ | use Time::Piece (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 3 | our $VERSION = '1.003'; | |
| 10 | |||
| 11 | 3 | our @EXPORT_OK = qw(parse_twitter_timestamp twitter_authorize_url); | |
| 12 | |||
| 13 | 3 | our $API_BASE_URL = 'https://api.twitter.com/1.1/'; | |
| 14 | 3 | our $OAUTH_BASE_URL = 'https://api.twitter.com/oauth/'; | |
| 15 | 3 | our $OAUTH2_BASE_URL = 'https://api.twitter.com/oauth2/'; | |
| 16 | |||
| 17 | 64 | ▶ | sub parse_twitter_timestamp { Time::Piece->strptime(shift, '%a %b %d %H:%M:%S %z %Y') } |
|
Subroutine
parse_twitter_timestamp: called CC=1 SCAR=0.0
Pod
documented
| |||
| 18 | |||
| 19 | 0 | ▶ | sub twitter_authorize_url { _oauth_url('authorize')->query(oauth_token => shift) } |
|
Subroutine
twitter_authorize_url: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 20 | |||
| 21 | 10 | ▶ | sub _api_url { Mojo::URL->new($API_BASE_URL)->path(shift) } |
|
Subroutine
_api_url: called CC=1 SCAR=0.0
| |||
| 22 | 2 | ▶ | sub _oauth_url { Mojo::URL->new($OAUTH_BASE_URL)->path(shift) } |
|
Subroutine
_oauth_url: called CC=1 SCAR=0.0
| |||
| 23 | 1 | ▶ | sub _oauth2_url { Mojo::URL->new($OAUTH2_BASE_URL)->path(shift) } |
|
Subroutine
_oauth2_url: called CC=1 SCAR=0.0
| |||
| 24 | |||
| 25 | 3 | 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<Mojo::WebService::Twitter::Util> contains utility functions used by | ||
| 40 | L<Mojo::WebService::Twitter> for interacting with the L<Twitter|https://twitter.com> | ||
| 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<Time::Piece> 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<Mojo::URL> 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 <dbook@cpan.org> | ||
| 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<Mojo::WebService::Twitter> | ||