Sample code for 30+ languages & platforms
Unicode C++

BrickLink OAuth1 using Chilkat REST

See more BrickLink Examples

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

Note: This example requires Chilkat v9.5.0.91 or greater (due to adjustments made within Chilkat to support bricklink OAuth1 needs).

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkOAuth1W.h>
#include <CkRestW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.h>

void ChilkatSample(void)
    {
    bool success = false;

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

    CkOAuth1W oauth1;

    oauth1.put_ConsumerKey(L"Your Consumer Key");
    oauth1.put_ConsumerSecret(L"Your Consumer Secret");
    oauth1.put_Token(L"Your OAuth1 Token");
    oauth1.put_TokenSecret(L"Your Token Secret");
    oauth1.put_SignatureMethod(L"HMAC-SHA1");

    CkRestW rest;

    rest.SetAuthOAuth1(oauth1,false);

    success = rest.Connect(L"api.bricklink.com",443,true,true);
    if (success == false) {
        wprintf(L"%s\n",rest.lastErrorText());
        return;
    }

    CkStringBuilderW sbResponse;
    success = rest.FullRequestNoBodySb(L"GET",L"/api/store/v1/orders?direction=in",sbResponse);
    if (success == false) {
        wprintf(L"%s\n",rest.lastErrorText());
        return;
    }

    wprintf(L"Response status code = %d\n",rest.get_ResponseStatusCode());

    CkJsonObjectW json;
    json.LoadSb(sbResponse);
    json.put_EmitCompact(false);
    wprintf(L"%s\n",json.emit());
    }