IdHTTP App ID, Key 존재시
user System.JSON
var
s : String;
JSON : TJSONObject;
i : integer;
rec_Data : TStringStream;
Stream: TBytesStream;
begin
Stream := TBytesStream.Create;
IdHTTP1.Request.CustomHeaders.Add('x-pharmsearch-app: 000000');
IdHTTP1.Request.CustomHeaders.Add('x-pharmsearch-key: 0000000');
IdHTTP1.Request.ContentType := 'application/json; charset=utf-8';
IdHTTP1.Request.ContentEncoding := 'utf-8';
try
IdHTTP1.Get('http://000000000000000000', Stream, []);
Memo1.Text := TEncoding.UTF8.GetString(Stream.Bytes, 0, Stream.Size);
finally
FreeAndNil(Stream);
end;
========================2차
user IdHTTP,System.JSON, REST.Json;
procedure TForm1.API_Tex_User_Status(sUserID: String; iType: integer);
Const
API_APP : String = '000000000';
API_KEY : String = 'x0000000000000000000';
CONTENTTYPE : String = 'pplication/json; charset=utf-8';
CONTENTENCODENG : String = 'utf-8';
URL_USER_STATUS : String = 'http://00000000000/%s';
var
IdHttp_API : TIdHTTP;
J_Obj : TJSONObject;
J_Value : TJSONValue;
B_Stream : TBytesStream;
begin
IdHttp_API := TIdHTTP.Create;
B_Stream := TBytesStream.Create;
try
try
IdHttp_API.Request.CustomHeaders.Add(API_APP);
IdHttp_API.Request.CustomHeaders.Add(API_KEY);
IdHttp_API.Request.ContentType := CONTENTTYPE;
IdHttp_API.Request.ContentEncoding := CONTENTENCODENG;
IdHttp_API.Get(URL_USER_STATUS, B_Stream, []);
var sJSON : string := TEncoding.UTF8.GetString(B_Stream.Bytes, 0, B_Stream.Size);
J_Obj := TJSONObject.ParseJSONValue(sJSON) as TJSONObject;
J_Value := J_Obj as TJSONValue;
Memo1.Lines.Text := TJSON.Format(J_Value);
Memo1.Lines.Add(J_Value.GetValue<string>('statusCode')) ;
Memo1.Lines.Add(J_Value.GetValue<string>('statusDescription')) ;
except on E: Exception do
ShowMessage(E.Message);
end;
finally
FreeAndNil(IdHttp_API);
FreeAndNil(B_Stream);
end;
end;
'Delphi Tip > 인터넷' 카테고리의 다른 글
델파이 JSON 생성 (서브아이템포함) (0) | 2021.12.14 |
---|---|
idHTTP JSON Post 방법 (0) | 2021.12.13 |
웹브라우저에 HTML 코드 밀어넣기 (0) | 2021.12.08 |
현재 떠 있는 모든 IE 찾기 및 닫기 (0) | 2021.12.07 |
델파이에서 원하는 주소로 크롬실행 (0) | 2021.12.06 |
댓글