(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_CkHttp.h>
#include <C_CkStringBuilder.h>
#include <C_CkJsonObject.h>
void ChilkatSample(void)
{
HCkHttp http;
HCkStringBuilder sbResponseBody;
BOOL success;
HCkJsonObject jResp;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttp_Create();
// To use HTTP Digest Authentication, set the login and password, and also indicate that DigestAuth should be used.
CkHttp_putLogin(http,"api_username");
CkHttp_putPassword(http,"api_key");
CkHttp_putDigestAuth(http,TRUE);
sbResponseBody = CkStringBuilder_Create();
success = CkHttp_QuickGetSb(http,"https://my-shopware-shop.com/api/articles?limit=2",sbResponseBody);
if (success == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkStringBuilder_Dispose(sbResponseBody);
return;
}
jResp = CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,sbResponseBody);
CkJsonObject_putEmitCompact(jResp,FALSE);
printf("Response Body:\n");
printf("%s\n",CkJsonObject_emit(jResp));
CkHttp_Dispose(http);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
}
|