(Unicode C) Shopify OAuth2 Authentication: Get List of Products
Demonstrates how to send a simple HTTP GET request with OAuth2 to get a list of products. The OAuth2 access token was obtained from the Shopify developer console for the created custom app.
#include <C_CkHttpW.h>
void ChilkatSample(void)
{
HCkHttpW http;
const wchar_t *jsonStr;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
CkHttpW_SetRequestHeader(http,L"X-Shopify-Access-Token",L"admin_api_access_token");
jsonStr = CkHttpW_quickGetStr(http,L"https://mystore.myshopify.com/admin/api/2022-04/products.json");
if (CkHttpW_getLastMethodSuccess(http) != TRUE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
return;
}
wprintf(L"Response status code: %d\n",CkHttpW_getLastStatus(http));
wprintf(L"JSON response:\n");
wprintf(L"%s\n",jsonStr);
CkHttpW_Dispose(http);
}
|