Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
=head1 NAME | ||
|
||
Google::Plus - simple interface to Google+ | ||
|
||
=head1 SYNOPSIS | ||
|
||
use Google::Plus; | ||
use v5.10.1; | ||
|
||
my $plus = Google::Plus->new(key => $your_gplus_api_key); | ||
|
||
# get a person's profile | ||
my $user_id = '112708775709583792684'; | ||
my $person = $plus->person($user_id); | ||
say "Name: ", $person->{displayName}; | ||
|
||
# get this person's activities | ||
my $activities = $plus->activities($user_id); | ||
while ($activities->{nextPageToken}) { | ||
my $next = $activities->{nextPageToken}; | ||
for my $item (@{$activities->{items}}) { | ||
...; | ||
} | ||
$activities = $plus->activities($user_id, $next); | ||
} | ||
|
||
# get a specific activity | ||
my $post = 'z13uxtsawqqwwbcjt04cdhsxcnfyir44xeg'; | ||
my $act = $plus->activity($post); | ||
say "Activity: ", $act->{title}; | ||
|
||
=head1 DESCRIPTION | ||
|
||
This module lets you access Google+ people profiles and activities from | ||
Perl. Currently, only access to public data is supported; authenticated | ||
requests for C<me> and other private data will follow in a future | ||
release. | ||
|
||
This module is B<alpha> software, use at your own risk. | ||
|
||
=head1 ATTRIBUTES | ||
|
||
=head2 C<key> | ||
|
||
my $key = $plus->key; | ||
my $key = $plus->key('xxxxNEWKEYxxxx'); | ||
|
||
Google+ API key, used for retrieving content. Usually set using L</new>. | ||
|
||
=head2 C<ua> | ||
|
||
my $ua = $plus->ua; | ||
my $ua = $plus->ua(Mojo::UserAgent->new); | ||
|
||
User agent object that retrieves JSON from the Google+ API endpoint. | ||
Defaults to a L<Mojo::UserAgent> object. This object will use | ||
HTTP/HTTPS proxies when available (via C<HTTP_PROXY> and C<HTTPS_PROXY> | ||
environment variables.) | ||
|
||
=head1 METHODS | ||
|
||
L<Google::Plus> implements the following methods: | ||
|
||
=head2 C<new> | ||
|
||
my $plus = Google::Plus->new(key => $google_plus_api_key); | ||
|
||
Construct a new L<Google::Plus> object. Needs a valid Google+ API key, | ||
which you can get at L<https://code.google.com/apis/console>. | ||
|
||
=head2 C<person> | ||
|
||
my $person = $plus->person('userId'); | ||
my $person = $plus->person('userId', 'fields'); | ||
|
||
Get a Google+ person's public profile. Returns a L<Mojo::JSON> decoded | ||
hashref describing the person's profile in L<Portable | ||
Contacts|http://portablecontacts.net/draft-spec.html> format. If | ||
C<fields> is given, limit response to the specified fields; see the | ||
Partial Responses section of L<https://developers.google.com/+/api>. | ||
|
||
=head2 C<activities> | ||
|
||
my $acts = $plus->activities('userId'); | ||
my $acts = $plus->activities('userId', 'collection'); | ||
my $acts = $plus->activities('userId', 'collection', nextPage'); | ||
my $acts = $plus->activities('userId', 'collection', nextPage', 'fields'); | ||
|
||
Get person's list of public activities, returning a L<Mojo::JSON> | ||
decoded hashref describing the person's activities in L<Activity | ||
Streams|http://activitystrea.ms/specs/json/1.0> format; this method also | ||
accepts requesting partial responses if C<fields> is given. If | ||
C<collection> is given, use that as the collection of activities to | ||
list; the default is to list C<public> activities instead. If a | ||
C<nextPage> token is given, this method retrieves the next page of | ||
activities this person has. | ||
|
||
=head2 C<activity> | ||
|
||
my $post = $plus->activity('activityId') | ||
my $post = $plus->activity('activityId', fields'); | ||
|
||
Get a specific activity/post. Returns a L<Mojo::JSON> decoded hashref | ||
describing the activity in L<Activity | ||
Streams|http://activitystrea.ms/specs/json/1.0> format. If C<fields> is | ||
given, limit response to specified fields. | ||
|
||
=head1 SEE ALSO | ||
|
||
=over | ||
|
||
=item * L<Google+ API|http://developers.google.com/+/api> | ||
|
||
=item * L<Google+|https://plus.google.com> | ||
|
||
=item * L<Portable Contacts|http://portablecontacts.net> | ||
|
||
=item * L<Activity Streams|http://activitystrea.ms> | ||
|
||
=back | ||
|
||
=cut | ||
|
||
=head1 DEVELOPMENT | ||
|
||
Send pull requests to | ||
L<https://github.com/zakame/perl-google-plus>. You can also post issues there or at L<CPAN | ||
RT|https://rt.cpan.org/Public/Dist/Display.html?Name=Google-Plus>. | ||
|
||
=head1 AUTHOR | ||
|
||
Zak B. Elep, C<zakame@cpan.org> | ||
|
||
=head1 COPYRIGHT AND LICENSE | ||
|
||
This software is Copyright (c) 2011, Zak B. Elep. | ||
|
||
This is free software, you can redistribute it and/or modify it under | ||
the same terms as Perl language system itself. | ||
|
||
=cut |