8
=item * I<verbose>
=item * I<debug>
=back
=item B<data>( String )
Base64-encoded encrypted JSON-serialized data with unique user's payload, data hashes and secrets required for EncryptedPasspor
:Slip 1.1 { # https://api.adviceslip.com/
use v5.38;
use HTTP::Tiny;
use JSON::Tiny qw[decode_json];
use parent 'Exporter';
our %EXPORT_TAGS = ( all => [ our @EXPORT_OK = qw[adv
state $http
//= HTTP::Tiny->new( default_headers => { Accept => 'application/json' }, agent => sprintf '%s/%.2f ', __PACKAGE__, our $VERSION );
my $res = $http->get($uri);
ice is not found but we'll at least know when we have valid JSON
$res->{success} ? decode_json( $res->{content} ) : ();
}
#
sub advice ( $slip_id //= () ) {
my $res = _http
ocket qw( :ws );
use parent qw( WebSocket );
use Encode;
use HTTP::Status ();
use JSON ();
use Nice::Try;
use Socket qw( IPPROTO_TCP TCP_NODELAY );
use URI;
use WebSock
e => $code,
message => $data,
status => $status,
};
}
$data = JSON->new->convert_blessed->relaxed->utf8->encode( $data );
my $resp = WebSocket::Response->new(
) if there was error
## or result with the data returned as a result
# "The response contains a JSON object, which always has a Boolean field ‘ok’ and may have an optional String field ‘descri
WebSocket Server
=head1 SYNOPSIS
use WebSocket::Server;
use JSON;
my $origin = 'http://localhost';
my $j = JSON->new->relaxed->convert_blessed;
my $ws = WebSocket::Server->new(
0, type => 'user', message => "Hello" };
my $json = $j->encode( $hash );
$conn->send_utf8( $json );
},
utf8 => sub
ble). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of cu
/test-signature',
{ nonce => "9f952b2e-1675-4be8-bb39-6f4343803c2f" },
my $expect_json = 0,
);
return 1;
}
=head2 access_token
Get an access token.
my $access_token = $
Socket::Frame> object and the payload data are passed as arguments to the event handler.
use JSON;
$ws->on_recv(sub
{
my( $frame, $payload ) = @_;
if( $frame->is_binary )
elsif( $frame->is_text )
{
# do something else
my $hash = JSON::decode_json( $payload );
}
});
Any fatal error occurring in the callback are caught using
ss::TrueLayer::Signer;
use Try::Tiny::SmartCatch;
use Mojo::UserAgent;
use Carp qw/ croak /;
use JSON;
use Data::GUID;
my $MAX_REDIRECTS = 5;
has [ qw/ client_id client_secret kid / ] => (
is
quest_body = undef,
$expect_json = 1,
) {
# sign the request
my $idempotency_key = $self->idempotency_key;
my $json = $http_request_body
? JSON->new->utf8->canonical->encode(
te_path,
$idempotency_key,
$json,
);
return $self->_ua_request(
"https://" . $self->api_host . $absolute_path,
$json,
[
'Authorization' =>
ess::TrueLayer::Types;
use Try::Tiny::SmartCatch;
use Mojo::UserAgent;
use Carp qw/ croak /;
use JSON;
has 'scope' => (
is => 'rw',
isa => 'ArrayRef',
required => 0,
de
return $self;
}
my $url = "https://" . $self->host . "/connect/token";
my $json = JSON->new->utf8->canonical->encode(
{
grant_type => 'client_credentials',
join( " ",$self->scope->@* ),
}
);
my $res_content = $self->_ua_request( $url, $json );
# If any of these are missing, we get "interesting" errors from Moose
# constraint vi
ble). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of cu
L;
use File::Temp;
use File::Spec;
use File::Basename ();
use IO::File;
use Data::UUID;
use JSON;
use Encode ();
use File::Map;
use Class::Struct qw( struct );
use Devel::StackTrace;
use Ti
= '';
$self->{ 'external_port' } = '';
$self->{ 'external_path' } = '';
$self->{ 'encode_with_json' } = 1;
$self->{ 'cookie_file' } = '';
$self->{ 'browser' } = $BROWSER;
$self->{ 'timeout' } =
r} = File::Spec->tmpdir;
## Json configuration file
$self->{conf_file} = '';
$self->SUPER::init( @_ );
$self->{conf_data} = {};
if( $self->{conf_file} )
{
my $json = $self->conf_file( $self->{
0 seconds for example.
POST /csrf HTTP/1.1
Host: api.example.com
Accept: application/json, text/javascript, */*; q=0.01
Accept-Encoding: gzip, deflate, br
Referer: https://example
&Digest::SHA::sha256 ) . ".$ts";
The API returns it in a custom HTTP response header and/or in a JSON reply, something like:
HTTP/1.1 200 OK
Date: Thu, 27 Apr 2023 10:21:38 GMT
Server: A
5, max=99
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: application/json
{"token":"899106ee26933c654c33b0fac9adc93f2adad2c95ff30a4eeebe200fbfeafb6a.1682591199","code
use DateTime::TimeZone;
use File::Temp;
use File::Spec;
# For the JSON::true and JSON::false
use JSON;
use Net::API::Telegram::Number;
our( $VERSION ) = 'v0.100.2';
};
sub init
{
{
if( $self->_is_boolean( $k ) )
{
$hash->{ $k } = ( $self->{ $k } ? JSON::true : JSON::false );
}
else
{
$hash->{ $k } = $crawl->( $self->{ $k } );
chmod( 0666, $file );
return( 1 );
}
sub parent { return( shift->{_parent} ); }
sub TO_JSON
{
my $self = shift( @_ );
return( $self->can( 'as_string' ) ? $self->as_string : $self );
nfig service, use the C<config> key. The value is the path
to the file to read. By default, YAML, JSON, XML, and Perl files are
supported (via L<Config::Any>).
This works very much like a C<value> se
ble). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of cu
-json];
#~ @ARGV = qw[-h];
#~ @ARGV = qw[-evil];
#~ @ARGV = qw[-pirate];
#~ @ARGV = qw[-glax];
#~ @ARGV = qw[-flavors];
#
my $raw = 0;
my $flavor;
sub _echo ($insult) {
$raw && eval 'require JSON
::Tiny' ? JSON::Tiny::encode_json( {%$insult} ) : $insult;
}
GetOptions(
\my %h, 'language=s',
'help' => sub { pod2usage( -exitval => 1 ) },
'flavors!' => sub { exit !say 'Supported in
sult flavors: ' . join ', ', Acme::Insult::flavors() },
'json!' => \$raw,
'glax!' => sub { $flavor = 'glax' },
'evil!' => sub { $flavor = 'evil' },
'pirate!' => sub { $flavor
2json( $resp->decoded_content ) ||
return( $self->error( "Unable to parse the json data received from server: ", $self->error ) );
}
$self->{ 'resp' } = $resp;
return( $self );
}
sub data2json
provided to decode into json." ) ) if( !length( $data ) );
if( $unescape )
{
$data =~ s/\\\\r\\\\n/\n/gs;
$data =~ s/^\"|\"$//gs;
$data =~ s/\"\[|\]\"//gs;
}
my $json;
eval
{
local $SIG{
'__WARN__' } = sub{ };
local $SIG{ '__DIE__' } = sub{ };
$json = $self->{ 'json' }->decode( $data );
};
if( $@ )
{
my $fh = File::Temp->new( SUFFIX => '.js' );
my $file = $fh->filename;
ARGV = qw[-json];
#~ @ARGV = qw[-id 5 -json];
#~ @ARGV = qw[-json -id 333];
#~ @ARGV = qw[-all -json];
#~ @ARGV = qw[-id 216];
#
my $raw = 0;
my ( $id, $all );
sub _echo ($slip) { # JSON::Tiny is
loaded in Acme::Free::Advice::Unsolicited anyway
$raw ? JSON::Tiny::encode_json($slip) : $slip;
}
GetOptions( 'json' => \$raw, 'help' => sub { pod2usage( -exitval => 1 ) }, 'id=i' => \$id, 'all!'
_kk -id 5 -json # specific advice by ID but you're a robot
advice_kk -all # get all advice
advice_kk -help # get help
=head1 OPTIONS
-json
ble). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of cu