یک url داریم از یک سایت Https
https://api.binance.com/api/v1/ticke...symbol=BTCUSDT
تو دلفی 7 می خوایم بازش کنیم
حتی indy رو هم به ورژن 10 اپدیت کردم
ولی باز هم موقع باز کردن خطا می ده
ایا ر دلفی 7 راهی برای بازکردن سایت https هست ؟
Printable View
یک url داریم از یک سایت Https
https://api.binance.com/api/v1/ticke...symbol=BTCUSDT
تو دلفی 7 می خوایم بازش کنیم
حتی indy رو هم به ورژن 10 اپدیت کردم
ولی باز هم موقع باز کردن خطا می ده
ایا ر دلفی 7 راهی برای بازکردن سایت https هست ؟
این نمونه رو ببینید
uses WinInet;
.
.
.
function Internet_Get(URL: string): string;
var
NetHandle: HINTERNET;
UrlHandle: HINTERNET;
Buffer: array[0..1024] of Char;
BytesRead, TotalRead: dWord;
begin
Result := '';
NetHandle := InternetOpen('Delphi 5.x', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
if Assigned(NetHandle) then
begin
UrlHandle := InternetOpenUrl(NetHandle, PChar(Url), nil, 0, INTERNET_FLAG_RELOAD, 0);
if Assigned(UrlHandle) then
{ UrlHandle valid? Proceed with download }
begin
TotalRead := 0;
FillChar(Buffer, SizeOf(Buffer), 0);
repeat
Result := Result + Buffer;
FillChar(Buffer, SizeOf(Buffer), 0);
InternetReadFile(UrlHandle, @Buffer, SizeOf(Buffer), BytesRead);
TotalRead := TotalRead + BytesRead;
until BytesRead = 0;
InternetCloseHandle(UrlHandle);
Result := LeftStr(Result, TotalRead);
end
else
{ UrlHandle is not valid. Raise an exception. }
raise Exception.CreateFmt('Cannot open URL %s', [Url]);
InternetCloseHandle(NetHandle);
end
else
{ NetHandle is not valid. Raise an exception }
raise Exception.Create('Unable to initialize Wininet');
end;