(Unicode C++) Magento Request with OAuth1.0a Authentication
Demonstrates sending a Magento request with OAuth1.0a authentication. (Using the Magento 1.x REST API)
#include <CkHttpW.h>
#include <CkJsonObjectW.h>
void ChilkatSample(void)
{
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
bool success;
CkHttpW http;
http.put_OAuth1(true);
http.put_OAuthVerifier(L"");
http.put_OAuthConsumerKey(L"MAGENTO_CONSUMER_KEY");
http.put_OAuthConsumerSecret(L"MAGENTO_CONSUMER_SECRET");
http.put_OAuthToken(L"MAGENTO__TOKEN");
http.put_OAuthTokenSecret(L"MAGENTO_TOKEN_SECRET");
http.put_Accept(L"application/json");
const wchar_t *url = L"http://www.inart.com/api/rest/products/store/2?limit=20&page=1";
const wchar_t *jsonStr = http.quickGetStr(url);
if (http.get_LastMethodSuccess() != true) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
wprintf(L"Response status code = %d\n",http.get_LastStatus());
CkJsonObjectW json;
json.Load(jsonStr);
json.put_EmitCompact(false);
wprintf(L"%s\n",json.emit());
// Use this online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
}
|