Delphi DLL
Delphi DLL
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 Delphi DLL Downloads
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, JsonObject, Http;
...
procedure TForm1.Button1Click(Sender: TObject);
var
success: Boolean;
http: HCkHttp;
url: PWideChar;
jsonStr: PWideChar;
json: HCkJsonObject;
begin
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) then
begin
Memo1.Lines.Add(CkHttp__lastErrorText(http));
Exit;
end;
Memo1.Lines.Add('Response status code = ' + IntToStr(CkHttp_getLastStatus(http)));
json := CkJsonObject_Create();
CkJsonObject_Load(json,jsonStr);
CkJsonObject_putEmitCompact(json,False);
Memo1.Lines.Add(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);
end;