C
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 C Downloads
#include <C_CkHttp.h>
#include <C_CkJsonObject.h>
void ChilkatSample(void)
{
BOOL success;
HCkHttp http;
const char *url;
const char *jsonStr;
HCkJsonObject json;
success = FALSE;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttp_Create();
CkHttp_putOAuth1(http,TRUE);
CkHttp_putOAuthVerifier(http,"");
CkHttp_putOAuthConsumerKey(http,"MAGENTO_CONSUMER_KEY");
CkHttp_putOAuthConsumerSecret(http,"MAGENTO_CONSUMER_SECRET");
CkHttp_putOAuthToken(http,"MAGENTO__TOKEN");
CkHttp_putOAuthTokenSecret(http,"MAGENTO_TOKEN_SECRET");
CkHttp_putAccept(http,"application/json");
url = "http://www.inart.com/api/rest/products/store/2?limit=20&page=1";
jsonStr = CkHttp_quickGetStr(http,url);
if (CkHttp_getLastMethodSuccess(http) != TRUE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
return;
}
printf("Response status code = %d\n",CkHttp_getLastStatus(http));
json = CkJsonObject_Create();
CkJsonObject_Load(json,jsonStr);
CkJsonObject_putEmitCompact(json,FALSE);
printf("%s\n",CkJsonObject_emit(json));
// Use this online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
}