in reply to Re: How to format HTTP::Request for bit.ly api expand endpoint
in thread How to format HTTP::Request for bit.ly api expand endpoint
use LWP::UserAgent; use JSON::XS; our $browser = LWP::UserAgent->new(timeout => 30); my $url = 'https://api-ssl.bitly.com/v4/expand'; my $header = ['Authorization' => 'Bearer 1a2b3c4d5e']; # use a valid o +ne instead of this made-up one my $data = {"bitlink_id" => 'bit.ly/361RdUL'}; # note domain is includ +ed my $encoded_data = encode_json($data); my $r = HTTP::Request->new('POST', $url, $header, $encoded_data); my $response = $browser->request($r); my $foo = 1; if ($response->is_success) { print $response->decoded_content; } else { die $response->status_line; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How to format HTTP::Request for bit.ly api expand endpoint
by perlfan (Parson) on May 23, 2020 at 18:27 UTC |