WWW-OneAll

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN


    WWW::OneAll - OneAll API

SYNOPSIS

        use WWW::OneAll;
        my $connection_token;
        my $oneall = WWW::OneAll->new(
            subdomain   => 'your_subdomain',
            public_key  => 'pubkey12-629b-4020-83fe-38af46e27b06',
            private_key => 'prikey12-a7ec-48f5-b9bc-737eb74146a4',
        );
        my $data = $oneall->connection($connection_token) or die $oneall->errstr;

DESCRIPTION

    OneAll provides web-applications with a unified API for 30+ social
    networks.

METHODS

 new

      * subdomain

      * public_key

      * private_key

      all required. get from API Settings
      https://app.oneall.com/applications/application/settings/api/

 connections

 connection

    Connection API http://docs.oneall.com/api/resources/connections/

lib/WWW/OneAll.pm  view on Meta::CPAN


our $VERSION = '0.03';

use vars qw/$errstr/;
sub errstr { return $errstr }

sub new {    ## no critic (ArgUnpacking)
    my $class = shift;
    my %args  = @_ % 2 ? %{$_[0]} : @_;

    for (qw/subdomain public_key private_key/) {
        $args{$_} || croak "Param $_ is required.";
    }

    $args{endpoint} ||= "https://" . $args{subdomain} . ".api.oneall.com";
    $args{timeout}  ||= 60;                                                  # for ua timeout

    return bless \%args, $class;
}

sub __ua {

lib/WWW/OneAll.pm  view on Meta::CPAN

    my ($self, $method, $url, %params) = @_;

    $errstr = '';    # reset

    # Format the query params if exist
    my $ref_url_params = delete $params{query_params};
    my $query_params   = "?";
    $query_params = $query_params . join("&", @$ref_url_params) if $ref_url_params;

    my $ua     = $self->__ua;
    my $header = {Authorization => 'Basic ' . b64_encode($self->{public_key} . ':' . $self->{private_key}, '')};
    $header->{'Content-Type'} = 'application/json' if %params;
    my @extra = %params ? (json => \%params) : ();
    my $tx    = $ua->build_tx($method => $self->{endpoint} . $url . '.json' . $query_params => $header => @extra);
    $tx->req->headers->accept('application/json');

    $tx = $ua->start($tx);
    if ($tx->res->headers->content_type and $tx->res->headers->content_type =~ 'application/json') {
        return $tx->res->json;
    }
    if (!$tx->success) {

lib/WWW/OneAll.pm  view on Meta::CPAN


WWW::OneAll - OneAll API

=head1 SYNOPSIS

    use WWW::OneAll;
    my $connection_token;
    my $oneall = WWW::OneAll->new(
        subdomain   => 'your_subdomain',
        public_key  => 'pubkey12-629b-4020-83fe-38af46e27b06',
        private_key => 'prikey12-a7ec-48f5-b9bc-737eb74146a4',
    );
    my $data = $oneall->connection($connection_token) or die $oneall->errstr;

=head1 DESCRIPTION

OneAll provides web-applications with a unified API for 30+ social networks.

=head1 METHODS

=head2 new

=over

=item * subdomain

=item * public_key

=item * private_key

all required. get from API Settings L<https://app.oneall.com/applications/application/settings/api/>

=back

=head2 connections

=head2 connection

Connection API L<http://docs.oneall.com/api/resources/connections/>



( run in 0.242 second using v1.01-cache-2.11-cpan-4d50c553e7e )