Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 1fc49920b4
Fetching contributors…

Cannot retrieve contributors at this time

executable file 32 lines (23 sloc) 0.633 kB
#!/usr/bin/perl
use 5.010;
use strict;
use warnings;
use WebService::TWFY::API;
use JSON;
my $twfy = WebService::TWFY::API->new({
key => $ENV{TWFY_KEY}
}) or die $!;
my $rv = $twfy->query( 'getConstituency', {
postcode => 'SW129RW',
});
if ($rv->{is_success}) {
my $const = from_json($rv->{results});
say $const->{name};
my $rv = $twfy->query( 'getMP', {
constituency => $const->{name},
});
if ($rv->{is_success}) {
my $mp = from_json($rv->{results});
say "$mp->{first_name} $mp->{last_name}, $mp->{party}"
}
}
Jump to Line
Something went wrong with that request. Please try again.