Need help in Perl sample
Hello.
Please help me with sample Perl code, that will authorize and then request a profit_table. This code first send profit_table reqest (and receiving "Authorization reqired") and then send Authorize request:
#!/usr/local/bin/perl use strict; use warnings; use v5.10; use Mojo::UserAgent; use Data::Dumper; my $ua = Mojo::UserAgent->new; $ua->websocket('wss://ws.binaryws.com/websockets/v3?l=en&app_id=XXXX' => sub { #my app num here my ($ua, $tx) = @_; say 'WebSocket handshake failed!' and return unless $tx->is_websocket; $tx->on(json => sub { my ($tx, $data) = @_; say "Answer is: " . Dumper(\$data); }); $tx->send({json => { authorize => 'xxxxxxxxxxx' #my token here }}); $tx->send({json => { profit_table => 1 }}); }); Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
Answers
@sn1 you need to chain request, first you send
authorize
request and then check in$tx->on(json => sub {
ifmsg_type
of response isauthorize
then sendprofit_table
request