Home > Back-end >  I haven't touched the Delphi xe 10.3.3, a great god cannot obtain numerical after using TIDHTTP
I haven't touched the Delphi xe 10.3.3, a great god cannot obtain numerical after using TIDHTTP

Time:04-13

The function TForm1. PostMethod (Url: String; Data: UTF8String; Max: Integer) : String;
Var
PostData, RespData: TStringStream;
HTTP: TIdHTTP;
SSL: TIdSSLIOHandlerSocketOpenSSL;
The begin
RespData:=TStringStream. Create (");
PostData:=TStringStream. Create (Data); //personal judgment TStringStream here. The create (' data ') does not effect the
SSL:=TIdSSLIOHandlerSocketOpenSSL. Create;
HTTP:=TIdHTTP. Create;
HTTP. HandleRedirects:=true;
HTTP. IOHandler:=SSL;
Try
Try
If the HTTP=nil then
The Exit;
HTTP Post (Url, PostData, RespData); //an error here some Connection Closed Gracefully.
Result:=Utf8ToAnsi (RespData. DataString);
HTTP. Request. Referer:=Url;
Except,
On e: the Exception do
The begin
AddLog (e.M essage); //here is the log, ignore
Dec (Max);
If Max=0 then
The begin
Result:=';
The Exit;
end;
Result:=PostMethod (Url, Data, Max);
end;
end;
The finally
HTTP. Disconnect;
HTTP. Free;
SSL. Free;
FreeAndNil (RespData);
FreeAndNil (PostData);
end;
end;



Procedure TForm1. GetToken;
Var
Url, Access_Token, StrJson, results: the string;
Expires_IN: integer;
Root, Data: TJSONObject;
Node: IXMLNode;
ParamsStr: string;
LDocument: IXMLDocument;
Paramslist: TStringList;
SValue: String;
The begin
URL:=TokenUrl;
The LDocument: TXMLDocument.=the Create (nil);
LDocument. LoadFromXML (GetMethod (URL, 1));
Node:=LDocument. DocumentElement;
ReadXml (node, 'token' ParamsStr);// successful grab to Token - custom process server to return information into XML, and remove the token value
Paramslist:=TStringList. Create;
Try
Paramslist. Text:=ParamsStr; //hand into the token value data array token value of [Azh18=]
SValue:='& amp; Memberid=13455216875 ';
URL:=QueryVIPValue + Paramslist. Text; //URL results for - http://12.227.110.23:801/api/memV/query? The access token -=Azh18=
Data:=TJSONObject. Create;
Try
Data. AddPair (' Member ', '13455216875');
Memo2. Text:= PostMethod (URL, UTF8Encode Data. ToString (), 1) ;//breakpoint error here {Connection Closed Gracefully}, should be within the postmethod method, see above,
The finally
Data. Free;
end;
The finally
Paramslist. Free;
end;

end;

Service environment is as follows:
server interface definition:
Request: POST
Request address:/API/memV/query
Parameter description:
Type name must describe
MemV String true membership number
return parameter
Name the type description
Code number return code
The message string returned information
The amount number balance
Sample request
{" memv ":" 13455216875 "}

return sample
{" code ": 0,
"Message" : "ok,"
"The amount" : 50
}
  • Related