Let me ask you a question for POST

Asked 2 years ago, Updated 2 years ago, 79 views

In order to communicate the NAVER Papago NMT application with Retrofit2, the client and secret values are I didn't know where to put it and sent it, so I sent it for the parameter, but is it the wrong way?

There's no communication.

post

2022-09-21 17:38

1 Answers

If Naver Papago API is a problem, why don't you look for something about Naver Papago API. Papago

import os
import sys
import urllib.request

client_id = "YOUR_CLIENT_ID" # <--- Modify this
client_secret = "YOUR_CLIENT_SECRET" # <--- Modify this

encText = urllib.parse.quote ("Nice to meet you")
data = "source=ko&target=en&text=" + encText
url = "https://openapi.naver.com/v1/papago/n2mt"
request = urllib.request.Request(url)
request.add_header("X-Naver-Client-Id",client_id)
request.add_header("X-Naver-Client-Secret",client_secret)
response = urllib.request.urlopen(request, data=data.encode("utf-8"))
rescode = response.getcode()
if(rescode==200):
    response_body = response.read()
    print(response_body.decode('utf-8'))
else:
    print("Error Code:" + rescode)


2022-09-21 17:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.