Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
HTTP XMLRPC
See more HTTP Examples
Demonstrates an XML-RPC call to WordPress. WordPress ships with two test methods in its XML-RPC server, one of which is the "demo.sayHello" method. This example demonstrates sending the "demo.sayHello" XML-RPC request to Chilkat's cknotes.com Wordpress server.Chilkat Pascal (Lazarus/Delphi) Downloads
program ChilkatDemo;
// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
SysUtils,
CkDllLoader,
Chilkat.HttpResponse,
Chilkat.Http;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
http: THttp;
xmlReq: string;
resp: THttpResponse;
begin
success := False;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := THttp.Create;
xmlReq := '<?xml version="1.0"?><methodCall><methodName>demo.sayHello</methodName><params /></methodCall>';
resp := THttpResponse.Create;
success := http.HttpStr('POST','http://www.cknotes.com/xmlrpc.php',xmlReq,'utf-8','text/xml',resp);
if (success = False) then
begin
WriteLn(http.LastErrorText);
Exit;
end;
WriteLn(resp.BodyStr);
http.Free;
resp.Free;
end;
// ---------------------------------------------------------------------------
begin
try
RunDemo;
except
on E: Exception do
WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
end;
WriteLn;
{$IFDEF MSWINDOWS}
WriteLn('Press Enter to exit...');
ReadLn;
{$ENDIF}
end.