반응형
# 메세지 보내기
KAKAOWORK_URL = "https://api.kakaowork.com/v1"
KAKAOWORK_BOT_KEY = "카카오봇에서 발급받은 키"
headers = {
'Content-Type': 'application/json',
'Accept': '*/*',
'charset': 'UTF-8',
'Authorization': f'Bearer {KAKAOWORK_BOT_KEY}'
}
url = f"{KAKAOWORK_URL}/messages.send_by_email"
body = {
'email': user.email,
'text': user.text,
}
try:
response = requests.post(url, headers=headers, json=body)
return json.loads(response.text)
except Exception as e:
return {'error': f'{e}'}
테스트 방법
curl -X POST https://api.kakaowork.com/v1/messages.send_by_email \
-H "Authorization: Bearer {YOUR_APP_KEY}" \
-H "Content-Type: application/json" \
-d '{ "email": "{메시지를 수신할 사용자의 인증된 email 주소}", "text": "{전송할 채팅 메시지}" }'
반응형