WWW-Instapaper-Client
view release on metacpan or search on metacpan
lib/WWW/Instapaper/Client.pm view on Meta::CPAN
sub init {
my ($self, $config) = @_;
my %default;
# my $package = shift;
# my %config = @_;
# my ($self, %default);
%default = (
agent_string => 'WWW-Instapaper-Client/'.PACKAGE_VERSION,
api_url => 'https://www.instapaper.com/api',
http_proxy => $ENV{HTTP_PROXY},
http_proxyuser => $ENV{HTTP_PROXY_USERNAME},
http_proxypass => $ENV{HTTP_PROXY_PASSWORD},
username => $ENV{instapaper_user},
password => $ENV{instapaper_pass},
);
# $self = bless \%default, $package;
## make sure defaults are loaded
for (keys %default) { $self->{$_} = $default{$_} }
for (keys %$config) {
die "Invalid parameter '$_'" unless exists $self->{$_};
$self->{$_} = $config->{$_};
}
$self->{_ua} = LWP::UserAgent->new(
agent => $self->{agent_string},
);
## remember, this is the LOCALIZED %ENV variable - won't change live environment.
$ENV{HTTPS_PROXY} = (defined $self->{http_proxy} ? $self->{http_proxy} : $ENV{HTTP_PROXY});
$ENV{HTTPS_PROXY_USERNAME} = (defined $self->{http_proxyuser} ? $self->{http_proxyuser} : $ENV{HTTP_PROXY_USERNAME});
$ENV{HTTPS_PROXY_PASSWORD} = (defined $self->{http_proxypass} ? $self->{http_proxypass} : $ENV{HTTP_PROXY_PASSWORD});
$ENV{HTTP_PROXY} = (defined $self->{http_proxy} ? $self->{http_proxy} : $ENV{HTTP_PROXY});
$ENV{HTTP_PROXY_USERNAME} = (defined $self->{http_proxyuser} ? $self->{http_proxyuser} : $ENV{HTTP_PROXY_USERNAME});
$ENV{HTTP_PROXY_PASSWORD} = (defined $self->{http_proxypass} ? $self->{http_proxypass} : $ENV{HTTP_PROXY_PASSWORD});
# if (defined $self->{http_proxy)) {
# my $proxy_url = $self->{http_proxy};
# if (defined $self->{http_proxyuser}) {
# my $authstr = $self->{http_proxyuser};
# $authstr .= ":".$self->{http_proxypass} if defined $self->{http_proxypass};
# $proxy_url =~ s{(\w+?:)//}{$1//$authstr\@};
# warn "Updated Proxy URL to '$proxy_url'" if DEBUG;
# }
# $self->{_ua}->proxy(['http','https'], $proxy_url);
lib/WWW/Instapaper/Client.pm view on Meta::CPAN
The password for the user's Instapaper account. The user may not have a password, in which case, any
value works. Defaults to C<$ENV{instapaper_pass}>
=item api_url
The base URL for the Instapaper API. Defaults to C<https://www.instapaper.com/api>. You shouldn't need
to change this unless you're connecting to a non-Instapaper service that uses the same API.
=item http_proxy, http_proxyuser, http_proxypass
The path to an HTTPS-capable proxy, and the username and password as appropriate. The standard HTTP_PROXY
set of environment variables will work here; these are widely documented. You only need to specify these
if you have a proxy B<AND> you don't have the environment variables set.
=back
=item C<add>
my $result = $paper->add(
url => 'http://path.to/page', # required
title => 'Page title', # optional
( run in 0.751 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )