(Unicode C) Shopware Digest Authentication
Demonstrates using Digest access authentication for Shopware. For more information, see https://developers.shopware.com/developers-guide/rest-api/#digest-access-authentication
#include <C_CkHttpW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
HCkHttpW http;
HCkStringBuilderW sbResponseBody;
BOOL success;
HCkJsonObjectW jResp;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
// To use HTTP Digest Authentication, set the login and password, and also indicate that DigestAuth should be used.
CkHttpW_putLogin(http,L"api_username");
CkHttpW_putPassword(http,L"api_key");
CkHttpW_putDigestAuth(http,TRUE);
sbResponseBody = CkStringBuilderW_Create();
success = CkHttpW_QuickGetSb(http,L"https://my-shopware-shop.com/api/articles?limit=2",sbResponseBody);
if (success == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
jResp = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jResp,sbResponseBody);
CkJsonObjectW_putEmitCompact(jResp,FALSE);
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkJsonObjectW_emit(jResp));
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
}
|