자유롭게 질의 및 응답을 할 수 있는 게시판입니다. 개발자 여러분의 답변이 큰 도움이 됩니다. 
  • 제품설치/등록 오류 문의: 설치/등록 Q&A 이용 (제품 구매 고객 한정)

Delphi Rest Api 질문입니다.

2020.01.22 20:12

희망나라 조회 수:1041

본 게시판은 개발자들이 자유롭게 질문과 답변을 공유하는 게시판입니다.
* 따라서 최대한 정중하게 질문을 올려 주세요.
* 질문을 상세히 작성해 주실 수록 좋은 답변이 올라 옵니다.
* 다른 분들도 참고할 수 있도록 결과 댓글 필수(또는 감사 댓글)
(결과 댓글을 달지 않는 경우 다음 질문에 대한 답변이 달리지 않는 불이익이 있을 수 있습니다.)
-----------------------------------------------------------------------------------------------

Xe8 Vcl 로 개발중입니다.

네이버 Rest Api 중 쇼핑 API 을 json 으로 호출 합니다..


procedure TForm1.GetNaverShop(AGubun:string);
var
  Param: TRESTRequestParameter;
  Url, token: string;
  Stream: TMemoryStream;
  JSONResponse : TJSONObject;   //use System.JSON
  jValue       : TJSONValue;    // use System.JSON
begin
  Memo1.Lines.Clear;

  RESTClient1.BaseURL := 'https://openapi.naver.com';
  RESTClient1.Accept := '*/*';
  RESTClient1.AcceptCharset := 'UTF-8';
  RESTClient1.UserAgent := 'curl/7.49.1';

  RESTRequest1.Client := RESTClient1;
  RESTRequest1.Response := RESTResponse1;
  RESTRequest1.Method := rmGET;

  RESTRequest1.Resource := '/v1/search/shop.json?query={query}&display=10&start=1&sort=sim';
  RESTRequest1.Params.ParameterByName('query').Value := EDdescr.Text;

  Param := RESTRequest1.Params.AddHeader('X-Naver-Client-Id', 'myid');
  Param := RESTRequest1.Params.AddHeader('X-Naver-Client-Secret', 'my secret');
  Param.Options := [TRESTRequestParameterOption.poDoNotEncode];

  RESTRequest1.Execute;

  Memo1.Lines.Text := RESTResponse1.Content;

 

-------Execute-----하고 나면  아래 ---결과 파일-- 이 만들어 집니다.

 

  try
    Url := RESTResponse1.JSONValue.GetValue<String>('image'); //----(1)이부분에서 에러 발생
  Except
    On E:Exception do begin
      Memo1.lines.Add(e.Message);
      Exit;
    end;
  end;

  RESTClient2.BaseURL := Url;
  RESTRequest2.ExecuteAsync(procedure
    begin
      Stream := TMemoryStream.Create;
      try
        Stream.WriteData(RESTResponse2.RawBytes, RESTResponse2.ContentLength);
        //ImageControl1.Bitmap.LoadFromStream(Stream);
        Image1.Picture.Bitmap.LoadFromStream(Stream);// (2)
      finally
        Stream.Free;
      end;
    end
  );
  end;

 

질문)

(1)에서 에러 발생원인이 "image" 의 "" 와 관련이 있는건가요.?

(2)VCL에서 사용하기 위해 Image1 사용함 

 

감사합니다.

 

 

---결과 파일--

{
"lastBuildDate": "Wed, 22 Jan 2020 19:53:28 +0900",
"total": 1808,
"start": 1,
"display": 10,
"items": [
{
"title": "농심 <b>새우깡 400g</b>",
"link": "https://search.shopping.naver.com/gate.nhn?id=6725761862",
"image": "https://shopping-phinf.pstatic.net/main_6725761/6725761862.20191231185207.jpg",
"lprice": "2980",
"hprice": "70810",
"mallName": "네이버",
"productId": "6725761862",
"productType": "1"

},
{
"title": "농심 대용량 스낵 (지퍼백) <b>새우깡</b> 포스틱 꿀꽈배기 자갈치 오징어집 조청유과 감자깡",
"link": "https://search.shopping.naver.com/gate.nhn?id=82263818665",
"image": "https://shopping-phinf.pstatic.net/main_8226381/82263818665.3.jpg",
"lprice": "2850",
"hprice": "0",
"mallName": "농심공식몰",
"productId": "82263818665",
"productType": "2"

},
{
"title": "농심 매운 <b>새우깡 400g</b>",
"link": "https://search.shopping.naver.com/gate.nhn?id=8588558030",
"image": "https://shopping-phinf.pstatic.net/main_8588558/8588558030.20150622134018.jpg",
"lprice": "3090",
"hprice": "37740",
"mallName": "네이버",
"productId": "8588558030",
"productType": "1"

},
{
"title": "농심 매운<b>새우깡400g</b> 과자 봉지과자 스낵",
"link": "https://search.shopping.naver.com/gate.nhn?id=18674959336",
"image": "https://shopping-phinf.pstatic.net/main_1867495/18674959336.1.jpg",
"lprice": "3990",
"hprice": "0",
"mallName": "쿠팡",
"productId": "18674959336",
"productType": "2"

},
{
"title": "농심 <b>새우깡400g</b> 농심 새우깡 매운 <b>새우깡 400g</b> 노래방 대용량과자",
"link": "https://search.shopping.naver.com/gate.nhn?id=21667660865",
"image": "https://shopping-phinf.pstatic.net/main_2166766/21667660865.jpg",
"lprice": "2980",
"hprice": "0",
"mallName": "티몬",
"productId": "21667660865",
"productType": "2"

},
{
"title": "농심 새우깡 매운 <b>새우깡 400g</b> 노래방 대용량과자",
"link": "https://search.shopping.naver.com/gate.nhn?id=80132527240",
"image": "https://shopping-phinf.pstatic.net/main_8013252/80132527240.1.jpg",
"lprice": "3000",
"hprice": "0",
"mallName": "빅카트",
"productId": "80132527240",
"productType": "2"

},
{
"title": "농심 <b>새우깡 400G</b>",
"link": "https://search.shopping.naver.com/gate.nhn?id=7789394589",
"image": "https://shopping-phinf.pstatic.net/main_7789394/7789394589.jpg",
"lprice": "4100",
"hprice": "0",
"mallName": "롯데프레시",
"productId": "7789394589",
"productType": "2"

},
{
"title": "농심 <b>새우깡 400g</b>",
"link": "https://search.shopping.naver.com/gate.nhn?id=5743436445",
"image": "https://shopping-phinf.pstatic.net/main_5743436/5743436445.20191231184909.jpg",
"lprice": "3500",
"hprice": "29940",
"mallName": "네이버",
"productId": "5743436445",
"productType": "1"

},
{
"title": "(농심) 노래방 <b>새우깡 400G</b> X 6개 1박스",
"link": "https://search.shopping.naver.com/gate.nhn?id=11450498354",
"image": "https://shopping-phinf.pstatic.net/main_1145049/11450498354.1.jpg",
"lprice": "19300",
"hprice": "0",
"mallName": "대진물류",
"productId": "11450498354",
"productType": "2"

},
{
"title": "대용량 스낵 8종 골라담기 <b>새우깡400g</b> 외",
"link": "https://search.shopping.naver.com/gate.nhn?id=21606646713",
"image": "https://shopping-phinf.pstatic.net/main_2160664/21606646713.jpg",
"lprice": "2720",
"hprice": "0",
"mallName": "인터파크",
"productId": "21606646713",
"productType": "2"

}
]
}
 

번호 제목 글쓴이 날짜 조회 수
공지 [프로그래밍 강의] 2021.6~2021.12 관리자 2015.01.22 15769
공지 유용한 관련 사이트 관리자2 2014.03.20 54583
공지 본 게시판은 개발자 여러분들의 질문과 답변을 공유하는 공간입니다. 관리자 2012.01.10 98000
1753 RADSTUDIO XE3 컴포넌트 지원 관련 질문입니다 술그머니홍구 2014.11.20 756
1752 문서파일(Hwp,Execl,pdf)을 다운받을 수 있는 방법 좀 부탁드립니다. [1] 멋진비행 2014.11.20 1527
1751 [XE7] 컴포넌트 제작하여 설치했더니 문제점 발견되어 질문드립니다. [4] 사도성 2014.11.22 963
1750 RadStudio XE7 에서 IOS Simulator 실행시 오류 [3] 해뜨는식당ㅋㅋ 2014.11.25 2137
1749 FireDAC 사용시 [3] 아이러브 2014.11.26 988
1748 다른 언어로 만든 OCX 등록 후 사용 시 에러가 발생합니다. [1] file 앰버 2014.11.26 1197
1747 [Delphi XE7] 컴포넌트 내부개체 버그문제 다시 질문드립니다. [2] 사조성 2014.11.27 1147
1746 환경파일에서 "The imported project file could not be loaded. '', hexadecimal value 0x01, is an invalid character." 오류 발생 시 조치사항 [4] Humphery 2014.11.28 1363
1745 나침반 소스를 구하고 싶습니다. [1] songport 2014.12.01 1249
1744 프로젝트내 한글 전체 검색시 열린 파일에 대해서만 검색됨 [1] 미키네 2014.12.02 902
1743 ToolBar Command Error(View) [2] file 우석이 2014.12.07 774
1742 Multi Language 적용 관련하여 질문 드립니다. [1] 앰버 2014.12.09 1048
1741 [질문] Delphi XE7 - Check for Updates 대하여... [2] 델사냥 2014.12.10 818
1740 XE7에서 FireDAC를 이용하여 AccessDB사용시 배포 [3] 투덜이스머프 2014.12.10 2091
1739 XE7 에서 Firedac 과 DBexpress 데이타베이스 연결 [1] 정연광 2014.12.12 1415
1738 xe6,xe7에서 폼이 자유자재로 안됩니다 [1] 나빌레나 2014.12.16 988
1737 마이그레이션 시 uses 절과 코드에 빨간줄(구문오류)가 발생할 경우 팁 Humphery 2014.12.20 885
1736 [DelphiXE7] 컨트롤을 동적생성하여 해제하면 Form을 닫을 수 없게 됩니다. [3] file 사조성 2014.12.21 1446
1735 XE7에서는 개선이 되었는지 궁금합니다. [1] ScorpioM 2014.12.22 777
1734 질문) intraweb 한글깨짐 [2] file 피터 2014.12.23 1123