Net-Twitter-Lite

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.008.
Build.PL
Changes
LICENSE
MANIFEST
META.json
META.yml
README
dist.ini
examples/oauth_desktop.pl
examples/oauth_webapp.pl
lib/Net/Twitter/Lite.pm
lib/Net/Twitter/Lite.pod
lib/Net/Twitter/Lite/API/V1.pm
lib/Net/Twitter/Lite/API/V1_1.pm
lib/Net/Twitter/Lite/Error.pm
lib/Net/Twitter/Lite/WithAPIv1_1.pm
lib/Net/Twitter/Lite/WithAPIv1_1.pod
lib/Net/Twitter/Lite/WrapResult.pm
t/00-compile.t

README  view on Meta::CPAN


    request_access_token

      Returns list including the access token, access token secret,
      user_id, and screen_name for this user. Takes a HASH of arguments.
      The verifier argument is required. See "OAUTH EXAMPLES".

      The user must have authorized this app at the url given by
      get_authorization_url first.

      For desktop applications, the Twitter authorization page will present
      the user with a PIN number. Prompt the user for the PIN number, and
      pass it as the verifier argument to request_access_token.

      Returns the access token and access token secret but also sets them
      internally so that after calling this method, you can immediately
      call API methods requiring authentication.

    get_authorization_url(callback => $callback_url)

      Get the URL used to authorize the user. Returns a URI object. For web
      applications, pass your applications callback URL as the callback
      parameter. No arguments are required for desktop applications
      (callback defaults to oob, out-of-band).

    get_authentication_url(callback => $callback_url)

      Get the URL used to authenticate the user with "Sign in with Twitter"
      authentication flow. Returns a URI object. For web applications, pass
      your applications callback URL as the callback parameter. No
      arguments are required for desktop applications (callback defaults to
      oob, out-of-band).

    xauth($username, $password)

      Exchanges a username and password for OAuth tokens. Your application
      must be approved for XAuth access by Twitter for this method to work.
      Twitter does not grant XAuth access for web applications except for a
      brief period of time to allow them to switch form Basic
      authentication to OAuth authentication.

README  view on Meta::CPAN


    Net::OAuth::Simple must be installed in order to use OAuth and an error
    will be thrown if OAuth is attempted without it. Net::Twitter::Lite
    does not require Net::OAuth::Simple, making OAuth an optional feature.

 OAUTH EXAMPLES

    See the examples directory included in this distribution for full
    working examples using OAuth.

    Here's how to authorize users as a desktop app mode:

      use Net::Twitter::Lite;
    
      my $nt = Net::Twitter::Lite->new(
          consumer_key    => "YOUR-CONSUMER-KEY",
          consumer_secret => "YOUR-CONSUMER-SECRET",
      );
    
      # You'll save the token and secret in cookie, config file or session database
      my($access_token, $access_token_secret) = restore_tokens();

examples/oauth_desktop.pl  view on Meta::CPAN

#!/usr/bin/perl
#
# Net::Twitter::Lite - OAuth desktop app example
#
use warnings;
use strict;

use Net::Twitter::Lite::WithAPIv1_1;
use File::Spec;
use Storable;
use Data::Dumper;

# You can replace the consumer tokens with your own;
# these tokens are for the Net::Twitter example app.
my %consumer_tokens = (
    consumer_key    => 'v8t3JILkStylbgnxGLOQ',
    consumer_secret => '5r31rSMc0NPtBpHcK8MvnCLg2oAyFLx5eGOMkXM',
);

# $datafile = oauth_desktop.dat
my (undef, undef, $datafile) = File::Spec->splitpath($0);
$datafile =~ s/\..*/.dat/;

my $nt = Net::Twitter::Lite::WithAPIv1_1->new(ssl => 1, %consumer_tokens);
my $access_tokens = eval { retrieve($datafile) } || [];

if ( @$access_tokens ) {
    $nt->access_token($access_tokens->[0]);
    $nt->access_token_secret($access_tokens->[1]);
}

lib/Net/Twitter/Lite.pod  view on Meta::CPAN

Note that the credentials may be wrong and so the request may fail.

=item request_access_token

Returns list including the access token, access token secret, user_id, and
screen_name for this user. Takes a HASH of arguments. The C<verifier> argument
is required.  See L</OAUTH EXAMPLES>.

The user must have authorized this app at the url given by C<get_authorization_url> first.

For desktop applications, the Twitter authorization page will present the user
with a PIN number.  Prompt the user for the PIN number, and pass it as the
C<verifier> argument to request_access_token.

Returns the access token and access token secret but also sets them internally
so that after calling this method, you can immediately call API methods
requiring authentication.

=item get_authorization_url(callback => $callback_url)

Get the URL used to authorize the user.  Returns a C<URI> object.  For web
applications, pass your applications callback URL as the C<callback> parameter.
No arguments are required for desktop applications (C<callback> defaults to
C<oob>, out-of-band).

=item get_authentication_url(callback => $callback_url)

Get the URL used to authenticate the user with "Sign in with Twitter"
authentication flow.  Returns a C<URI> object.  For web applications, pass your
applications callback URL as the C<callback> parameter.  No arguments are
required for desktop applications (C<callback> defaults to C<oob>, out-of-band).

=item xauth($username, $password)

Exchanges a username and password for OAuth tokens. Your application must be
approved for XAuth access by Twitter for this method to work.  Twitter does not
grant XAuth access for web applications except for a brief period of time to
allow them to switch form Basic authentication to OAuth authentication.

=item access_token

lib/Net/Twitter/Lite.pod  view on Meta::CPAN


L<Net::OAuth::Simple> must be installed in order to use OAuth and an error will
be thrown if OAuth is attempted without it.  Net::Twitter::Lite does not
I<require> Net::OAuth::Simple, making OAuth an optional feature.

=head2 OAUTH EXAMPLES

See the C<examples> directory included in this distribution for full working
examples using OAuth.

Here's how to authorize users as a desktop app mode:

  use Net::Twitter::Lite;

  my $nt = Net::Twitter::Lite->new(
      consumer_key    => "YOUR-CONSUMER-KEY",
      consumer_secret => "YOUR-CONSUMER-SECRET",
  );

  # You'll save the token and secret in cookie, config file or session database
  my($access_token, $access_token_secret) = restore_tokens();



( run in 0.412 second using v1.01-cache-2.11-cpan-299005ec8e3 )