TFbmHttp

Diese Klasse gehört zur Unit Http.
Quelltext-Beispiel:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
var
  Http: TFbmHttp;
  ResponseText: string;

begin
  Http := TFbmHttp.Create;
 
  try
    Http.ContentType := 'application/json';

    Http.PostEx(
      'https://app.fakejson.com/q',
      '{"token": "AwyBv-DAUrxbzVB6Y-33uw","data": ' +
        '{"id": "personNickname","email": "internetEmail","gender": "personGender","last_login": ' +
          '{"date_time": "dateTime|UNIX","ip4": "internetIP4"}' +
        '}' +
      '}',
      ResponseText
    );

    Item.AddToProtocol(ResponseText);
  finally
    Http.Free;
  end;
end.
Feiertage ermitteln:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var
  Http: TFbmHttp;
  Response: string;
  Json: TFbmJsonObject;

begin
  Http := TFbmHttp.Create;

  try
    if Http.GetEx2('https://feiertage-api.de/api/?jahr=' + IntToStr(YearOf(Now)), Response) then
    begin
      Json := TFbmJsonObject.Create;

      try
        try
          Json.LoadFromStr(Response);

          if Json.Has('NI') then
          begin
            if Json.Items['NI'].O.Has('Ostermontag') and (Json.Items['NI'].O.Items['Ostermontag'].DataType = jdtObject) then
            begin
              if Json.Items['NI'].O.Items['Ostermontag'].O.Has('datum') and (Json.Items['NI'].O.Items['Ostermontag'].O.Items['datum'].DataType = jdtString) then
              begin
                Item.AddToProtocol('Ostermontag ist am: ' + Json.Items['NI'].O.Items['Ostermontag'].O.Items['datum'].S);
              end;
            end;
          end;
        except
          // Hier ggf. Fehlerbehandlung, falls keine gültigen JSON-Daten vorliegen.
        end;
      finally
        Json.Free;
      end;
    end;
  finally
    Http.Free;
  end;
end.

Methoden:

Dies sind die Methoden, welche durch diese Klasse zur Verfügung gestellt werden.
Name
Parameter
Rückgabetyp
Abort Keine Prozedur
Clear Keine Prozedur
Create Keine Konstruktor
Delete URL string
Request TStream
Response TStream
Boolean
DeleteEx URL string
Request string
out Response string
Boolean
DeleteEx2 URL string
Request TStream
Boolean
DeleteEx3 URL string
Request string
Boolean
ExecRpc URL string
Method string
Params TFbmJsonArray
TFbmJsonObject
ExecRpcEx URL string
Method string
Params string
TFbmJsonObject
ExecRpcEx2 URL string
Method string
Params string
TFbmJsonObject
Get URL string
Response TStream
Boolean
GetEx URL string
Response TStrings
Boolean
GetEx2 URL string
out Response string
Boolean
GetEx3 URL string Boolean
Post URL string
Request TStream
Response TStream
Boolean
PostEx URL string
Request string
out Response string
Boolean
PostEx2 URL string
Request TStream
Boolean
PostEx3 URL string
Request string
Boolean
Put URL string
Request TStream
Response TStream
Boolean
PutEx URL string
Request string
out Response string
Boolean
PutEx2 URL string
Request TStream
Boolean
PutEx3 URL string
Request string
Boolean

Eigenschaften:

Dies sind die Eigenschaften, welche durch diese Klasse zur Verfügung gestellt werden.