#!/usr/bin/perl
use DBIx::Connector;
use Encode;
use JSON;
use Data::Dumper;
my $dbuser = ((getpwuid $>)[0]);
my $dbname = $dbuser;
my $dbpass = "";
my $conn;
my $fname;
my $lang;
for (my $i = 0; $i
t, msgid, message_json
from nls_msgid join nls_message using (id_nls_msgid)
where short = ?
union
select coalesce(context, '') context, msgid_plural, message_json
from nls_m
}
);
my %ctx;
for my $row (@$messages) {
my $decoded_msg = from_json($row->{message_json});
my $message = $row->{message_json};
if (ref $decoded_msg eq 'ARRAY' && @$decoded_msg == 1) {
subs
mail-address,first-name,last-name,formatted-name,picture-url)';
$req->uri->query_form(format => 'json');
$req->header(Authorization => 'Bearer ' . $self->{session}->data->{oauth_access_token}{$self-
use strict;
use warnings;
use PEF::Front::Config;
use PEF::Front::Connector;
use Geo::IPfree;
use JSON;
use Storable;
use MLDBM::Sync;
use MLDBM qw(MLDBM::Sync::SDBM_File Storable);
use Fcntl qw(:DEFA
sage_json;
if (cfg_no_nls) {
$message_json = to_json([$msgid]);
} else {
db_connect->run(
sub {
($message_json, $id_nls_msgid) = $_->selectrow_array(
q{
select message_json, id
= ?) and short = ?
},
undef, $msgid, $msgid, $lang
);
if (not defined $message_json) {
$found = 0;
($id_nls_msgid) = $_->selectrow_array(
q{
select id_nls_msg
package PEF::Front::Request;
use strict;
use warnings;
use JSON;
use Carp ();
use utf8;
use Encode;
use PEF::Front::Headers;
use PEF::Front::File;
use PEF::Front::Config;
use XML::Simple;
use URI;
my
ms} || {};
$self->{params} = {%$p, %$q};
if (exists $self->{params}{json}) {
my $form = eval {from_json $self->{params}{json}} || {};
$self->logger({level => "warn", message => $@}) if $@;
$s
($ct, 'application/json') == 0) {
$read_body_sub->();
my $from_json = $self->{raw_body};
if (substr($self->{raw_body}, 0, 2) eq '%7') {
$from_json =~ tr/+/ /;
$from_json =~ s/%([a-fA-F0-9]
nt::Oauth;
use strict;
use warnings;
use URI;
use LWP::UserAgent;
use HTTP::Request::Common;
use JSON;
use PEF::Front::Config;
use PEF::Front::Session;
my $coro_ae_lwp;
BEGIN {
if ($INC{'Coro/AnyE
ri {0}
sub _required_state {1}
sub _returns_state {1}
sub _decode_token {
decode_json($_[1]);
}
sub user_info_scope {
my ($self) = @_;
cfg_oauth_scopes($self->{service})->{user_inf
_get_user_info_request);
if ($response && $response->decoded_content) {
$info = eval {decode_json $response->decoded_content};
$exception = $@;
} else {
$exception = "timeout";
}
} els
cookie>.
See C<cfg_parse_extra_params> in L<PEF::Front::Config>.
=item B</ajax$Method>
Returns JSON answer, doesn't support redirects. By default doesn't parse
parameters from URI path. Method name
package PEF::Front::Ajax;
use strict;
use warnings;
use Encode;
use JSON;
use URI::Escape;
use Template::Alloy;
use Data::Dumper;
use Scalar::Util qw(blessed);
use PEF::Front::Config;
use PEF::Front:
EF::Front::Validator;
use PEF::Front::NLS;
use PEF::Front::Response;
my $json_utf8_object;
BEGIN {
$json_utf8_object = JSON->new->utf8->convert_blessed;
}
sub ajax {
my ($request, $context) = @_;
ext_post_hook($context);
}
my $vreq = eval {validate(\%request, $context)};
my $response;
my $json = $src eq 'ajax';
$src = 'submit' if $src eq 'get';
my $new_loc;
if (!$@) {
my $as = get_me
e}),
client_secret => cfg_oauth_client_secret($self->{service})
],
Accept => 'application/json';
}
sub _get_user_info_request {
my ($self) = @_;
my $req = GET 'https://api.github.com/user',
type('application/json');
$req->header(Authorization => 'Bearer ' . $self->{session}->data->{oauth_access_token}{$self->{service}});
$req->header(Accept => 'application/json');
$req;
}
sub
f) = @_;
my $req = GET 'https://login.yandex.ru/info';
$req->uri->query_form(
format => 'json',
oauth_token => $self->{session}->data->{oauth_access_token}{$self->{service}}
);
$req;
}
s
's also special parameter B<json> that has to be encoded JSON value.
When it's present, then parameters are overwritten from this decoded JSON.
Request parsing detects JSON or XML content-types and c
ML
---
params:
select@:
Another way to submit array or hash is to use C<json> form data field or
to post JSON or XML content.
Array of files has type 'array'.
=item Maximum or minimum size
header.
=item B<answer_data>
Replaces answer hash with C<answer_data> field before encoding to JSON.
It can be only B<ARRAY> or B<HASH> reference.
=item B<answer_http_response>
Uses supplied HTT
#!/usr/bin/perl
use DBIx::Connector;
use Locale::PO;
use JSON;
use Encode;
use SQL::Abstract;
my $dbuser = ((getpwuid $>)[0]);
my $dbname = $dbuser;
my $dbpass = "";
my $conn;
my $fname;
my $language
_json($msgstr) ne $nls_message->{message_json}) {
$conn->run(
sub {
$_->do(
'update nls_message set message_json = ? where id_nls_msgid = ? and short = ?',
undef, to_json(
ert into nls_message (id_nls_msgid, short, message_json) values(?, ?, ?)',
undef, $nls_msgid->{id_nls_msgid},
$nls_lang->{short}, to_json($msgstr)
);
}
);
++$inserted;
}