| 1 | package URL::Social::LinkedIn; | ||||||||||
| 2 | 6 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 6 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 6 | extends 'URL::Social::BASE'; | |||||||||
| 6 | |||||||||||
| 7 | =head1 NAME | ||||||||||
| 8 | |||||||||||
| 9 | URL::Social::LinkedIn - Interface to the LinkedIn API. | ||||||||||
| 10 | |||||||||||
| 11 | =head1 DESCRIPTION | ||||||||||
| 12 | |||||||||||
| 13 | Do not use this module directly. Access it from L<URL::Social> instead; | ||||||||||
| 14 | |||||||||||
| 15 | use URL::Social; | ||||||||||
| 16 | |||||||||||
| 17 | my $social = URL::Social->new( | ||||||||||
| 18 | url => '...', | ||||||||||
| 19 | ); | ||||||||||
| 20 | |||||||||||
| 21 | print $social->linkedin->share_count . "\n"; | ||||||||||
| 22 | |||||||||||
| 23 | =head1 METHODS | ||||||||||
| 24 | |||||||||||
| 25 | =cut | ||||||||||
| 26 | |||||||||||
| 27 | 6 | has 'share_count' => ( isa => 'Maybe[Int]', is => 'ro', lazy_build => 1 ); | |||||||||
| 28 | |||||||||||
| 29 | =head2 share_count | ||||||||||
| 30 | |||||||||||
| 31 | Returns the number of times the URL in question has been shared among LinkedIn | ||||||||||
| 32 | users. | ||||||||||
| 33 | |||||||||||
| 34 | Returns undef if it fails to retrieve the data from LinkedIn. | ||||||||||
| 35 | |||||||||||
| 36 | =cut | ||||||||||
| 37 | |||||||||||
| 38 | 1 | ▶ | sub _build_share_count { | ||||||||
|
Subroutine
_build_share_count: called CC=2 SCAR=7.4
| |||||||||||
| 39 | 1 | my $self = shift; | |||||||||
| 40 | |||||||||||
| 41 | 1 | my $url = 'http://www.linkedin.com/countserv/count/share?format=json&url=' . $self->url; | |||||||||
| 42 | |||||||||||
| 43 | 1 | ▶ | if ( my $share_count = $self->get_url_json($url)->{count} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | 1 | return $share_count; | |||||||||
| 45 | } | ||||||||||
| 46 | else { | ||||||||||
| 47 | 0 | return undef; | |||||||||
| 48 | } | ||||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | # | ||||||||||
| 52 | # The End | ||||||||||
| 53 | # | ||||||||||
| 54 | 6 | __PACKAGE__->meta->make_immutable; | |||||||||
| 55 | |||||||||||
| 56 | 6 | 1; | |||||||||
| 57 | |||||||||||
| 58 | =head1 LICENSE AND COPYRIGHT | ||||||||||
| 59 | |||||||||||
| 60 | Copyright 2013-2014 Tore Aursand. | ||||||||||
| 61 | |||||||||||
| 62 | This program is free software; you can redistribute it and/or modify it | ||||||||||
| 63 | under the terms of the the Artistic License (2.0). You may obtain a | ||||||||||
| 64 | copy of the full license at: | ||||||||||
| 65 | |||||||||||
| 66 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||||||||||
| 67 | |||||||||||
| 68 | Any use, modification, and distribution of the Standard or Modified | ||||||||||
| 69 | Versions is governed by this Artistic License. By using, modifying or | ||||||||||
| 70 | distributing the Package, you accept this license. Do not use, modify, | ||||||||||
| 71 | or distribute the Package, if you do not accept this license. | ||||||||||
| 72 | |||||||||||
| 73 | If your Modified Version has been derived from a Modified Version made | ||||||||||
| 74 | by someone other than you, you are nevertheless required to ensure that | ||||||||||
| 75 | your Modified Version complies with the requirements of this license. | ||||||||||
| 76 | |||||||||||
| 77 | This license does not grant you the right to use any trademark, service | ||||||||||
| 78 | mark, tradename, or logo of the Copyright Holder. | ||||||||||
| 79 | |||||||||||
| 80 | This license includes the non-exclusive, worldwide, free-of-charge | ||||||||||
| 81 | patent license to make, have made, use, offer to sell, sell, import and | ||||||||||
| 82 | otherwise transfer the Package with respect to any patent claims | ||||||||||
| 83 | licensable by the Copyright Holder that are necessarily infringed by the | ||||||||||
| 84 | Package. If you institute patent litigation (including a cross-claim or | ||||||||||
| 85 | counterclaim) against any party alleging that the Package constitutes | ||||||||||
| 86 | direct or contributory patent infringement, then this Artistic License | ||||||||||
| 87 | to you shall terminate on the date that such litigation is filed. | ||||||||||
| 88 | |||||||||||
| 89 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER | ||||||||||
| 90 | AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. | ||||||||||
| 91 | THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||||||||||
| 92 | PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY | ||||||||||
| 93 | YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR | ||||||||||
| 94 | CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR | ||||||||||
| 95 | CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, | ||||||||||
| 96 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||||||