Registriert seit: 8. Jan 2007
472 Beiträge
|
AW: Thingspeak - Datenabruf
2. Mai 2023, 23:20
Mit mORMot gibt es mehrere Wege. Einer ist:
Delphi-Quellcode:
uses
mormot.core.base,
mormot.core.search,
mormot.net.client;
type
TCsvItem = packed record
created_at: TDateTime;
entry_id: Integer;
field1: Double;
field2: Double;
field3: Double;
field4: String;
end;
TCsvItems = array of TCsvItem;
var
url: RawUtf8;
content: RawByteString;
csvItems: TCsvItems;
begin
url := ' https://api.thingspeak.com/channels/1671193/feeds.csv?start="2023-05-02T19:20"';
content := HttpGet( url);
if (content <> ' ')
and DynArrayLoadCsv(csvItems, content, TypeInfo(TCsvItems)) then
begin
var count: Integer := Length(csvItems);
if count > 0 then
begin
ShowMessage(Format(' Anzahl: %d', [Length(csvItems)]));
with csvItems[0] do
ShowMessage(Format(' %s-%d-%f-%f-%f-%d' , [DateToStr(created_at), entry_id, field1, field2, field3, field4.Trim.ToInteger]));
end;
end;
Bis bald...
Thomas
Geändert von mytbo ( 2. Mai 2023 um 23:36 Uhr)
Grund: Units hinzugefügt
|
|
Zitat
|