ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 네이버LAB 포토에디터 API (http://s.lab.naver.com/pe/api)
    정보 2011. 11. 3. 19:40
    네이버LAB 포토에디터 API (http://s.lab.naver.com/pe/api)

    서버에 올려진 이미지를 수정하고자 할 때
    GET방식으로 하면 되는데
    http://s.lab.naver.com/pe/api?i=1&t=2 중간쯤의
    http://s.lab.naver.com/pe/service?import=http%3A%2F%2Fexample.com%2Fuser%2Fsomebody%2F1234.jpg&exportTo=http%3A%2F%2Fexample.com%2Fmyexample%2Fimage_post.jsp%3Fpid%3D1244711925301&exportMethod=GET&exportField=file&exportTitle=example.com%EC%97%90+%EC%A0%80%EC%9E%A5%ED%95%98%EA%B8%B0
    와 같이 파라미터들을 주~욱 붙여 넣어주면 된다.

    파일업로드 필드(input type=file)을 통한 사용자 로컬PC 이미지를 수정하고
    서버에 저장하고자 할 때

    exportMethod="POST" 를 주고 시도해 보았으나 exportTo(처리)에서 exportField를 받지 못하여
    결국 아래와 같이 exportMethod="BROWSER" 주고 GET 방식으로 받아서 처리하였다.

    폼(입력)
    01 <H3>네이버 포토에디터 연동 테스트</H3>
    02
    03 <FORM id=frm encType=multipart/form-data method=post name=frm action=http://s.lab.naver.com/pe/service>
    04 <INPUT id=import name=import type=file>
    05 <INPUT id=exportTo name=exportTo value=http://test.womennews.co.kr/dev/naver/naverPeDown.asp?fname={파일명} type=hidden>
    06 <INPUT id=exportMethod name=exportMethod value=BROWSER type=hidden> <!-- GET / POST / BROWSER -->
    07 <INPUT id=exportMIMEType name=exportMIMEType value=image/jpeg type=hidden>
    08 <INPUT id=exportField name=exportField value=imageData type=hidden>
    09 <INPUT id=exportTitle name=exportTitle value=Save type=hidden>
    10 <INPUT id=redirectTo name=redirectTo value=http://test.womennews.co.kr/dev/naver/naverPe.asp type=hidden> <!-- 저장후 이동할 URL -->
    11
    12 <INPUT id=btnPicEdit value=사진편집 type=submit>
    13 </FORM>
    처리(저장)
    01 <%
    02 Session.Codepage = 949
    03 Response.Charset = "euc-kr"
    04
    05 '// Save Path
    06 Dim savePath, saveDir
    07 savePath = "/data"
    08 saveDir = Server.Mappath(savePath)
    09
    10 Response.Write("<P>Params From NaverLAB<BR>
    11 [GET]<BR>
    12 ")
    13 For Each strKey In Request.QueryString
    14 Response.Write(strKey &" = """& Request.QueryString(strKey) &"""<BR>
    15 ")
    16 Next
    17 Response.Write("[POST]<BR>
    18 ")
    19 For Each strKey In Request.Form
    20 Response.Write(strKey &" = """& Request.Form(strKey) &"""<BR>
    21 ")
    22 Next
    23 Response.Write("</P>
    24 ")
    25
    26 fname = Request.Querystring("fname")
    27 If fname = "" Then Response.Write("fname is Nothing<BR>
    28 "): Response.End
    29
    30 Dim imageData, imageSaveName
    31 imageData = Request.QueryString("imageData")
    32 If imageData = "" Then Response.Write("imageData is Nothing<BR>
    33 "): Response.End
    34 Response.Write("Photo In NaverLAB :<BR>
    35 [img src='"& Request.QueryString("imageData") &"' border='0' alt='Photo In NaverLAB' /]")
    36 imageSaveName = fname &".jpg"
    37
    38 Dim objXML, binXML
    39 Set objXML = CreateObject("Microsoft.XMLHTTP")
    40 objXML.Open "GET", imageData, False
    41 objXML.Send
    42 binXML = objXML.ResponseBody
    43 Set objXML = Nothing
    44
    45 Dim objADO
    46 Set objADO = CreateObject("ADODB.Stream")
    47 objADO.Type = 1
    48 objADO.Open
    49 objADO.Write binXML
    50 objADO.SaveToFile saveDir &"\"& imageSaveName, 2
    51 Set objADO = Nothing
    52
    53 Response.Write("Saved Photo :<BR>
    54 [img src='"& savePath &"/"& imageSaveName &"' border='0' alt='Saved Photo' /]")
    55 %>



    펌: http://itzone.tistory.com/254

    댓글

Designed by Tistory.