image2data

Der Tech-Blog

...weitermachen, wo OCR aufhört

Plugin "HTTP/HTTPS-Requests" (i2dxHTTP)

Feb 212015

Mit Hilfe des image2data-Plugins "HTTP/HTTPS-Requests" (i2dxHTTP) lassen sich Anfragen an Webserver entweder über die "GET"- oder die "POST"-Methode stellen. Das Ergebnis der Anfragen enthält die Antwort des Webservers.

// ****************************************************************
// * sample_i2dxhttp.i2dspt                                       *
// *                                                              *
// * Sample script for the i2dxHTTP (http-/https requests) plugin *
// * REQUIRES THE INSTALLED PLUGIN TO COMPILE AND RUN!            *
// *                                                              *
// * Press F9 to execute the code or F7/F8 to debug it            *
// *                                                              *
// * Contact www.norpa.eu if the plugin is required but missing   *
// ****************************************************************
 
{$I i2dxHTTP}
 
var
  oHeaders: TStringList;
 
begin
  // Perform a GET request without additional http headers
  i2dShowMessage(i2dxHTTPGetData('http://httpbin.org/get?parameter1=hello&parameter2=world', '', nil));
 
  // Perform a POST request with additional http header; here, the postdata locates in the "data"-section
  i2dShowMessage(i2dxHTTPPostData('http://httpbin.org/post?parameter1=hello&parameter2=world', '', 'parameter3=look at me', oHeaders));
 
  // Perform a POST request with additional http header; here, the postdata locates in the "form"-section
  oHeaders := TStringList.Create;
 
  try
    oHeaders.Add('Content-Type: application/x-www-form-urlencoded');
    i2dShowMessage(i2dxHTTPPostData('http://httpbin.org/post?parameter1=hello&parameter2=world', '', 'parameter3=' + i2dEncodeURL('look at me'), oHeaders));
  finally
    oHeaders.Free;
  end;
end.

Atom

powered by Nibbleblog