Alen IBRIC
Feb 6, 2025

Maybe your version is not suppported with this dll. You can use Indy instead ot this code. Change like this : unit OpenWeatherMap;

interface

uses

System.SysUtils, System.Classes, IdHTTP, IdSSLOpenSSL;

type

TOpenWeatherMap = class(TComponent)

private

FHttpClient: TIdHTTP;

FApiKey: string;

FLatitude: Double;

FLongitude: Double;

FLanguage: string;

FUnits: string;

FResponse: string;

function GetUrl: string;

public

constructor Create(AOwner: TComponent); override;

destructor Destroy; override;

procedure GetWeather;

property Response: string read FResponse;

published

property ApiKey: string read FApiKey write FApiKey;

property Latitude: Double read FLatitude write FLatitude;

property Longitude: Double read FLongitude write FLongitude;

property Language: string read FLanguage write FLanguage;

property Units: string read FUnits write FUnits;

end;

implementation

constructor TOpenWeatherMap.Create(AOwner: TComponent);

begin

inherited;

FHttpClient := TIdHTTP.Create(nil);

FHttpClient.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(FHttpClient);

end;

destructor TOpenWeatherMap.Destroy;

begin

FHttpClient.Free;

inherited;

end;

function TOpenWeatherMap.GetUrl: string;

begin

Result := Format('https://api.openweathermap.org/data/2.5/weather?lat=%f&lon=%f&appid=%s&lang=%s&units=%s',

[FLatitude, FLongitude, FApiKey, FLanguage, FUnits]);

end;

procedure TOpenWeatherMap.GetWeather;

begin

FResponse := FHttpClient.Get(GetUrl);

end;

end.

Alen IBRIC
Alen IBRIC

Responses (1)