알림톡 전송을 위해 사전 승인된 알림톡템플릿코드가 필요 합니다.
curl -X POST https://omni.ibapi.kr/v1/send/alimtalk \
-H "content-type: application/json" \
-H "Accept: application/json" \
-H "Authorization:Bearer 발급받은 토큰" \
-d '{"templateCode":"알림톡 템플릿 코드", "msgType":"AT", "text":"알림톡 메시지 내용", "senderKey":"카카오 비즈메시지 발신프로필키", "to":"수신번호", "ref":"참조필드"}'
import java.io.*;
import okhttp3.*;
public class Main {
public static void main(String []args) throws IOException{
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"senderKey\": \"발신 프로필키\", \"msgType\": \"알림톡 메시지 타입(AT/AI)\", \"to\": \"수신번호\", \"templateCode\": \"알림톡 템플릿코드\", \"text\": \"알림톡 메시지 내용\", \"ref\": \"참조필드\"}");
Request request = new Request.Builder()
.url("https://omni.ibapi.kr/v1/send/alimtalk")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer 발급받은 토큰")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
}
}
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://omni.ibapi.kr/v1/send/alimtalk"
method := "POST"
payload := strings.NewReader(`{"senderKey": "발신 프로필키", "msgType": "알림톡 메시지 타입(AT/AI)", "to": "수신번호", "templateCode": "알림톡 템플릿코드", "text": "알림톡 메시지 내용", "ref": "참조필드"}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", "Bearer 발급받은 토큰")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://omni.ibapi.kr/v1/send/alimtalk',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"senderKey": "발신 프로필키", "msgType": "알림톡 메시지 타입(AT/AI)", "to": "수신번호", "templateCode": "알림톡 템플릿코드", "text": "알림톡 메시지 내용", "ref": "참조필드"}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer 발급받은 토큰'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://omni.ibapi.kr/v1/send/alimtalk',
'headers': {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer 발급받은 토큰'
},
body: JSON.stringify({
"senderKey": "발신 프로필키",
"msgType": "알림톡 메시지 타입(AT/AI)",
"to": "수신번호",
"templateCode": "알림톡 템플릿코드",
"text": "알림톡 메시지 내용",
"ref": "참조필드"
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://omni.ibapi.kr/v1/send/alimtalk");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer 발급받은 토큰");
var content = new StringContent("{\"senderKey\": \"발신 프로필키\", \"msgType\": \"알림톡 메시지 타입(AT/AI)\", \"to\": \"수신번호\", \"templateCode\": \"알림톡 템플릿코드\", \"text\": \"알림톡 메시지 내용\", \"ref\": \"참조필드\"}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Accept", "application/json");
myHeaders.append("Authorization", "Bearer 발급받은 토큰");
var raw = JSON.stringify({
"senderKey": "발신 프로필키",
"msgType": "알림톡 메시지 타입(AT/AI)",
"to": "수신번호",
"templateCode": "알림톡 템플릿코드",
"text": "알림톡 메시지 내용",
"ref": "참조필드"
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://omni.ibapi.kr/v1/send/alimtalk", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
import http.client
import json
conn = http.client.HTTPSConnection("omni.ibapi.kr")
payload = json.dumps({
"senderKey": "발신 프로필키",
"msgType": "알림톡 메시지 타입(AT/AI)",
"to": "수신번호",
"templateCode": "알림톡 템플릿코드",
"text": "알림톡 메시지 내용",
"ref": "참조필드"
})
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer 발급받은 토큰'
}
conn.request("POST", "/v1/send/alimtalk", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require "uri"
require "json"
require "net/http"
url = URI("https://omni.ibapi.kr/v1/send/alimtalk")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request["Authorization"] = "Bearer 발급받은 토큰"
request.body = JSON.dump({
"senderKey": "발신 프로필키",
"msgType": "알림톡 메시지 타입(AT/AI)",
"to": "수신번호",
"templateCode": "알림톡 템플릿코드",
"text": "알림톡 메시지 내용",
"ref": "참조필드"
})
response = https.request(request)
puts response.read_body
{
"code": "A000",
"result": "Success",
"msgKey": "발급된 메시지 키",
"ref": "요청시 입력한 데이터"
}
{
"code": "A010",
"result": "Cannot parse JSON"
}
{
"code": "A001",
"result": "Expired token"
}
{
"code": "A020",
"result": "Rate limit exceeded"
}
{
"code": "A999",
"result": "Unknown error"
}
curl -X POST https://omni.ibapi.kr/v1/send/friendtalk \
-H "content-type: application/json" \
-H "Accept: application/json" \
-H "Authorization:Bearer 발급받은 토큰" \
-d '{"msgType":"FT", "text":"친구톡 메시지 내용", "senderKey":"카카오 비즈메시지 발신프로필키", "to":"수신번호", "ref":"참조필드"}'
import java.io.*;
import okhttp3.*;
public class Main {
public static void main(String []args) throws IOException{
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"senderKey\": \"발신 프로필키\", \"msgType\": \"친구톡 메시지 타입(FT/FI/FW)\", \"to\": \"수신번호\", \"text\": \"친구톡 메시지 내용\",\"ref\": \"참조필드\"}");
Request request = new Request.Builder()
.url("https://omni.ibapi.kr/v1/send/friendtalk")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer 발급받은 토큰")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
}
}
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://omni.ibapi.kr/v1/send/friendtalk"
method := "POST"
payload := strings.NewReader(`{"senderKey": "발신 프로필키", "msgType": "친구톡 메시지 타입(FT/FI/FW)", "to": "수신번호", "text": "친구톡 메시지 내용","ref": "참조필드"}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", "Bearer 발급받은 토큰")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://omni.ibapi.kr/v1/send/friendtalk',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{"senderKey": "발신 프로필키", "msgType": "친구톡 메시지 타입(FT/FI/FW)", "to": "수신번호", "text": "친구톡 메시지 내용","ref": "참조필드"}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer 발급받은 토큰'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://omni.ibapi.kr/v1/send/friendtalk',
'headers': {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer 발급받은 토큰'
},
body: JSON.stringify({
"senderKey": "발신 프로필키",
"msgType": "친구톡 메시지 타입(FT/FI/FW)",
"to": "수신번호",
"text": "친구톡 메시지 내용",
"ref": "참조필드"
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://omni.ibapi.kr/v1/send/friendtalk");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer 발급받은 토큰");
var content = new StringContent("{\"senderKey\": \"발신 프로필키\", \"msgType\": \"친구톡 메시지 타입(FT/FI/FW)\", \"to\": \"수신번호\", \"text\": \"친구톡 메시지 내용\",\"ref\": \"참조필드\"}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Accept", "application/json");
myHeaders.append("Authorization", "Bearer 발급받은 토큰");
var raw = JSON.stringify({
"senderKey": "발신 프로필키",
"msgType": "친구톡 메시지 타입(FT/FI/FW)",
"to": "수신번호",
"text": "친구톡 메시지 내용",
"ref": "참조필드"
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://omni.ibapi.kr/v1/send/friendtalk", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
import http.client
import json
conn = http.client.HTTPSConnection("omni.ibapi.kr")
payload = json.dumps({
"senderKey": "발신 프로필키",
"msgType": "친구톡 메시지 타입(FT/FI/FW)",
"to": "수신번호",
"text": "친구톡 메시지 내용",
"ref": "참조필드"
})
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer 발급받은 토큰'
}
conn.request("POST", "/v1/send/friendtalk", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require "uri"
require "json"
require "net/http"
url = URI("https://omni.ibapi.kr/v1/send/friendtalk")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request["Authorization"] = "Bearer 발급받은 토큰"
request.body = JSON.dump({
"senderKey": "발신 프로필키",
"msgType": "친구톡 메시지 타입(FT/FI/FW)",
"to": "수신번호",
"text": "친구톡 메시지 내용",
"ref": "참조필드"
})
response = https.request(request)
puts response.read_body
{
"code": "A000",
"result": "Success",
"msgKey": "발급된 메시지 키",
"ref": "요청시 입력한 데이터"
}
{
"code": "A010",
"result": "Cannot parse JSON"
}
{
"code": "A001",
"result": "Expired token"
}
{
"code": "A020",
"result": "Rate limit exceeded"
}
{
"code": "A999",
"result": "Unknown error"
}