Perl Requires Chilkat v9.5.0.91+
Perl
BrickLink OAuth1 using Chilkat REST
See more BrickLink Examples
Demonstrates sending an api.bricklink.com request with OAuth1 authentication using Chilkat REST.Chilkat Perl Downloads
use strict;
use warnings;
use Chilkat2;
# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
my $oauth1 = Chilkat2::OAuth1->new;
$oauth1->ConsumerKey('Your Consumer Key');
$oauth1->ConsumerSecret('Your Consumer Secret');
$oauth1->Token('Your OAuth1 Token');
$oauth1->TokenSecret('Your Token Secret');
$oauth1->SignatureMethod('HMAC-SHA1');
my $rest = Chilkat2::Rest->new;
$rest->SetAuthOAuth1($oauth1, 0);
my $success = $rest->Connect('api.bricklink.com', 443, 1, 1);
if (!$success) {
print $rest->LastErrorText, "\n";
exit;
}
my $sbResponse = Chilkat2::StringBuilder->new;
$success = $rest->FullRequestNoBodySb('GET', '/api/store/v1/orders?direction=in', $sbResponse);
if (!$success) {
print $rest->LastErrorText, "\n";
exit;
}
print 'Response status code = ', $rest->ResponseStatusCode, "\n";
my $json = Chilkat2::JsonObject->new;
$json->LoadSb($sbResponse);
$json->EmitCompact(0);
print $json->Emit(), "\n";