Sample code for 30+ languages & platforms
PHP Requires Chilkat v9.5.0.91+

BrickLink OAuth1 using Chilkat REST

See more BrickLink Examples

Demonstrates sending an api.bricklink.com request with OAuth1 authentication using Chilkat REST.

Chilkat PHP Downloads

PHP
<?php

use Chilkat2\JsonObject;
use Chilkat2\OAuth1;
use Chilkat2\Rest;
use Chilkat2\StringBuilder;

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

$oauth1 = new OAuth1();

$oauth1->ConsumerKey = 'Your Consumer Key';
$oauth1->ConsumerSecret = 'Your Consumer Secret';
$oauth1->Token = 'Your OAuth1 Token';
$oauth1->TokenSecret = 'Your Token Secret';
$oauth1->SignatureMethod = 'HMAC-SHA1';

$rest = new Rest();

$rest->SetAuthOAuth1($oauth1, false);

try {
    $rest->Connect('api.bricklink.com', 443, true, true);

    $sbResponse = new StringBuilder();
    $rest->FullRequestNoBodySb('GET', '/api/store/v1/orders?direction=in', $sbResponse);
} catch (\Chilkat2\Exception $e) {
    echo $e->getMessage(), "\n";
    exit;
}

echo 'Response status code = ', $rest->ResponseStatusCode, "\n";

$json = new JsonObject();
$json->LoadSb($sbResponse);
$json->EmitCompact = false;
echo $json->Emit(), "\n";