in reply to API Calls with RESTful & Trello
:P Go through the docs more slowly: https://trello.com/docs/gettingstarted/index.html. This should be fun to mess around with if you have the right packages: strictures, URI::QueryParam, JSON, YAML (not necessary, comment out if you like), Path::Tiny. Set your developer key in your environment or add to the script.
#!/usr/bin/env perl use 5.010; use strictures; use URI; use URI::QueryParam; use LWP::UserAgent; use JSON; use YAML; # Just for fun/readability. use Path::Tiny; use open qw( :encoding(UTF-8) :std ); $ENV{TRELLO_KEY} ||= "YouForgotToSetThis"; my $version = 1; # My guess/interpretation of URL spec. my $service = URI->new("https://api.trello.com/"); $service->query_param( key => $ENV{TRELLO_KEY} ); my $uri = $service->clone; # URI from docs -> https://trello.com/docs/gettingstarted/index.html $uri->path("/$version/board/4d5ea62fd76aa1136000000c"); # Uncomment to get TONS of data -> $uri->query_param( cards => "open" +); $uri->query_param( list_fields => "name,desc" ); my $response = LWP::UserAgent ->new ->get( $uri ); die $response->as_string unless $response->is_success; my $data = decode_json( $response->decoded_content ); print YAML::Dump( $data ); # Just to see in human-readable tree. my $outfile = path("ohai.json"); # Save the JSON to a file. $outfile->spew_utf8( $response->decoded_content ); say "Check $outfile for the JSON."; exit 0;
|
|---|