(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 <CkHttpW.h>
void ChilkatSample(void)
{
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttpW http;
http.SetRequestHeader(L"X-Shopify-Access-Token",L"admin_api_access_token");
const wchar_t *jsonStr = http.quickGetStr(L"https://mystore.myshopify.com/admin/api/2022-04/products.json");
if (http.get_LastMethodSuccess() != true) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
wprintf(L"Response status code: %d\n",http.get_LastStatus());
wprintf(L"JSON response:\n");
wprintf(L"%s\n",jsonStr);
}
|