Unicode C
Unicode C
Magento Request with OAuth1.0a Authentication
See more Magento Examples
Demonstrates sending a Magento request with OAuth1.0a authentication. (Using the Magento 1.x REST API)Chilkat Unicode C Downloads
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
BOOL success;
HCkHttpW http;
const wchar_t *url;
const wchar_t *jsonStr;
HCkJsonObjectW json;
success = FALSE;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
CkHttpW_putOAuth1(http,TRUE);
CkHttpW_putOAuthVerifier(http,L"");
CkHttpW_putOAuthConsumerKey(http,L"MAGENTO_CONSUMER_KEY");
CkHttpW_putOAuthConsumerSecret(http,L"MAGENTO_CONSUMER_SECRET");
CkHttpW_putOAuthToken(http,L"MAGENTO__TOKEN");
CkHttpW_putOAuthTokenSecret(http,L"MAGENTO_TOKEN_SECRET");
CkHttpW_putAccept(http,L"application/json");
url = L"http://www.inart.com/api/rest/products/store/2?limit=20&page=1";
jsonStr = CkHttpW_quickGetStr(http,url);
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));
json = CkJsonObjectW_Create();
CkJsonObjectW_Load(json,jsonStr);
CkJsonObjectW_putEmitCompact(json,FALSE);
wprintf(L"%s\n",CkJsonObjectW_emit(json));
// Use this online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
}