#!/usr/bin/perl
require 5.010_001;
use strict;
use warnings;
use lib '.';
use Data::Dumper;
use JSON;
use LWP::UserAgent 6.03;
use CGI ();
use Encode;
my ($inhalt,%cb);
comm(\%cb);
# hier oben sind keine encodierungen erwünscht
foreach my $ref (@{$cb{data}{content}}) {
# $inhalt .= Encode::encode('ISO-8859-15',$ref->{bankname})."
\n"; # bringt sauber alle Umlaute raus, auch €
$inhalt .= $ref->{bankname}."
\n";
}
my $cgi = CGI->new();
print $cgi->header(
-content_type => 'text/html',
-charset => 'ISO-8859-15'
),$inhalt
;
sub comm {
my ($cb) = @_;
my $url = 'https://dev.sepatools.eu/supported_banks.json';
my $ua = LWP::UserAgent->new();
$ua->credentials('dev.sepatools.eu:443',"dev.sepatools.eu",'dtest','8cd9cddec4cdf6780211e4c51d2f287befdff9b7');
my $response = $ua->get($url);
if ($response->is_success) {
# my $content = $response->content;
my $content = Encode::encode('ISO-8859-15',$response->content); # bringt Köln
# $cb->{data} = JSON->new->utf8->decode($content); # bringt auch Köln
$cb->{data} = JSON->new->decode($content);
}
}