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

Example: Http.SetUrlVar method

Demonstrates the HTTP SetUrlVar method.

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkHttpW.h>
#include <CkStringBuilderW.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkHttpW http;

    const wchar_t *url = L"https://finnhub.io/api/v1/quote?symbol={$symbol}&token={$api_key}";

    //  When the request is sent, the {$symbol} is replaced with "MSFT"
    //  and the {$api_key} is replaced with "1234567890ABCDEF"
    http.SetUrlVar(L"symbol",L"MSFT");
    http.SetUrlVar(L"api_key",L"1234567890ABCDEF");

    CkStringBuilderW sbJson;
    success = http.QuickGetSb(url,sbJson);
    if (success == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    int statusCode = http.get_LastStatus();
    if (statusCode != 200) {
        wprintf(L"Status code: %d\n",statusCode);
        wprintf(L"Error Message:\n");
        wprintf(L"%s\n",sbJson.getAsString());
    }
    else {
        wprintf(L"JSON Stock Quote:\n");
        wprintf(L"%s\n",sbJson.getAsString());
    }

    //  Output:

    //  JSON Stock Quote:
    //  {"c":522.98,"d":0.5,"dp":0.0957,"h":524.51,"l":520.86,"o":524.28,"pc":522.48,"t":1755271948}
    }