t;
our $VERSION; # to be able to test in devel environment
use Carp qw(croak);
use JSON::MaybeXS qw/encode_json/;
# Attributes to be saved to preserve the session.
my @session = qw/access_token to
ned $refresh;
$token;
}
#--------------
sub to_json()
{ my $self = shift;
encode_json $self->session_freeze;
}
*to_string = \&to_json; # until v0.50
sub session_freeze(%)
{ my ($self
use MIME::Base64 qw(encode_base64);
use LWP::UserAgent ();
use URI ();
use JSON::MaybeXS qw/decode_json/;
use Scalar::Util qw/blessed/;
use Encode qw/encode/;
use constant MIME_
cation/json is often not correctly configured: is not
# (yet) an apache pre-configured extension :(
if(my $params = eval {decode_json $content} )
{ # content is JSON
get($request);
my $response = $session->get($header, $content);
print $session->to_string; # JSON
# probably better to set new(auto_refresh), but you may do:
$session->refresh if $session->e
you store this in a
MySQL database. Perl's JSON module will output utf8 by default.
=item $obj-E<gt>B<to_json>()
Freeze this object into JSON. The JSON syntax is also used by the OAuth2
protocol,