String reqURL = “https://kapi.kakao.com/v2/api/talk/memo/default/send”;
try {
URL url = new URL(reqURL);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod(“POST”);
conn.setRequestProperty(“Content-Type”, “application/x-www-form-urlencoded”);
conn.setRequestProperty(“Authorization”, "Bearer " + access_token);
conn.setDoOutput(true);
// POST 요청에 필요로 요구하는 파라미터 스트림을 통해 전송
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(conn.getOutputStream()));
StringBuilder sb = new StringBuilder();
JSONObject jobj_link = new JSONObject();
jobj_link.put("web_url", "");
jobj_link.put("mobile_web_url", "");
JSONObject jobj = new JSONObject();
jobj.put("object_type", "text");
jobj.put("text", "로그인하셨습니다.");
jobj.put("link", jobj_link.toString());
jobj.put("button_title", "바로확인");
sb.append("template_object=" + jobj.toString());
콘솔 로그
access_token : HTj2qF79FfNXhMpgFvUgpMpeaGb_dyn3leOcaPOECinI2gAAAYV8m5ws
sb : template_object={“object_type”:“text”,“link”:"{“web_url”:"",“mobile_web_url”:""}",“text”:“로그인하셨습니다.”,“button_title”:“바로확인”}
responseCode : 403
responseMessage : Forbidden
java.io.IOException: Server returned HTTP response code: 403 for URL: https://kapi.kakao.com/v2/api/talk/memo/default/send
로그인 토큰까지 모두 받고서 바로 발송보냈는데
403에러 발생합니다.
API 이용동의도 설정했습니다.