Gửi mã hoá đầu-cuối (RSA)
curl --request POST \
--url https://business.adflex.vn/api/v1/messages/rsa \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"template_id": "123456",
"recipients": [
{
"rsa_phone": "<string>",
"template_data": {},
"tracking_id": "<string>"
}
],
"send_at": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://business.adflex.vn/api/v1/messages/rsa"
payload = {
"template_id": "123456",
"recipients": [
{
"rsa_phone": "<string>",
"template_data": {},
"tracking_id": "<string>"
}
],
"send_at": "2023-11-07T05:31:56Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
template_id: '123456',
recipients: [{rsa_phone: '<string>', template_data: {}, tracking_id: '<string>'}],
send_at: '2023-11-07T05:31:56Z'
})
};
fetch('https://business.adflex.vn/api/v1/messages/rsa', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://business.adflex.vn/api/v1/messages/rsa",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'template_id' => '123456',
'recipients' => [
[
'rsa_phone' => '<string>',
'template_data' => [
],
'tracking_id' => '<string>'
]
],
'send_at' => '2023-11-07T05:31:56Z'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://business.adflex.vn/api/v1/messages/rsa"
payload := strings.NewReader("{\n \"template_id\": \"123456\",\n \"recipients\": [\n {\n \"rsa_phone\": \"<string>\",\n \"template_data\": {},\n \"tracking_id\": \"<string>\"\n }\n ],\n \"send_at\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://business.adflex.vn/api/v1/messages/rsa")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"template_id\": \"123456\",\n \"recipients\": [\n {\n \"rsa_phone\": \"<string>\",\n \"template_data\": {},\n \"tracking_id\": \"<string>\"\n }\n ],\n \"send_at\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://business.adflex.vn/api/v1/messages/rsa")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"template_id\": \"123456\",\n \"recipients\": [\n {\n \"rsa_phone\": \"<string>\",\n \"template_data\": {},\n \"tracking_id\": \"<string>\"\n }\n ],\n \"send_at\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"accepted": 123,
"total": 123,
"scheduled_at": "2023-11-07T05:31:56Z",
"results": [
{
"msg_id": "<string>",
"tracking_id": "<string>",
"error": "<string>"
}
]
}{
"error": {
"code": 401,
"message": "API key không hợp lệ hoặc đã bị thu hồi"
}
}{
"error": {
"code": 401,
"message": "API key không hợp lệ hoặc đã bị thu hồi"
}
}{
"error": {
"code": 401,
"message": "API key không hợp lệ hoặc đã bị thu hồi"
}
}{
"error": {
"code": 401,
"message": "API key không hợp lệ hoặc đã bị thu hồi"
}
}{
"error": {
"code": 401,
"message": "API key không hợp lệ hoặc đã bị thu hồi"
}
}Gửi tin
Gửi mã hoá đầu-cuối (RSA)
Gửi tin mã hoá đầu-cuối. AdFlex không lưu số điện thoại.
Thông số mã hoá: RSA/ECB/OAEP, hash OAEP = SHA-256, MGF1 = SHA-1. Khoá công khai lấy tại Console → Official Account → Thiết lập RSA key.
Thư viện chuẩn của Node.js và Go không hỗ trợ chọn MGF1. Xem hướng dẫn Gửi RSA.
Scope: messages:send
POST
/
api
/
v1
/
messages
/
rsa
Gửi mã hoá đầu-cuối (RSA)
curl --request POST \
--url https://business.adflex.vn/api/v1/messages/rsa \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"template_id": "123456",
"recipients": [
{
"rsa_phone": "<string>",
"template_data": {},
"tracking_id": "<string>"
}
],
"send_at": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://business.adflex.vn/api/v1/messages/rsa"
payload = {
"template_id": "123456",
"recipients": [
{
"rsa_phone": "<string>",
"template_data": {},
"tracking_id": "<string>"
}
],
"send_at": "2023-11-07T05:31:56Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
template_id: '123456',
recipients: [{rsa_phone: '<string>', template_data: {}, tracking_id: '<string>'}],
send_at: '2023-11-07T05:31:56Z'
})
};
fetch('https://business.adflex.vn/api/v1/messages/rsa', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://business.adflex.vn/api/v1/messages/rsa",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'template_id' => '123456',
'recipients' => [
[
'rsa_phone' => '<string>',
'template_data' => [
],
'tracking_id' => '<string>'
]
],
'send_at' => '2023-11-07T05:31:56Z'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://business.adflex.vn/api/v1/messages/rsa"
payload := strings.NewReader("{\n \"template_id\": \"123456\",\n \"recipients\": [\n {\n \"rsa_phone\": \"<string>\",\n \"template_data\": {},\n \"tracking_id\": \"<string>\"\n }\n ],\n \"send_at\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://business.adflex.vn/api/v1/messages/rsa")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"template_id\": \"123456\",\n \"recipients\": [\n {\n \"rsa_phone\": \"<string>\",\n \"template_data\": {},\n \"tracking_id\": \"<string>\"\n }\n ],\n \"send_at\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://business.adflex.vn/api/v1/messages/rsa")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"template_id\": \"123456\",\n \"recipients\": [\n {\n \"rsa_phone\": \"<string>\",\n \"template_data\": {},\n \"tracking_id\": \"<string>\"\n }\n ],\n \"send_at\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"accepted": 123,
"total": 123,
"scheduled_at": "2023-11-07T05:31:56Z",
"results": [
{
"msg_id": "<string>",
"tracking_id": "<string>",
"error": "<string>"
}
]
}{
"error": {
"code": 401,
"message": "API key không hợp lệ hoặc đã bị thu hồi"
}
}{
"error": {
"code": 401,
"message": "API key không hợp lệ hoặc đã bị thu hồi"
}
}{
"error": {
"code": 401,
"message": "API key không hợp lệ hoặc đã bị thu hồi"
}
}{
"error": {
"code": 401,
"message": "API key không hợp lệ hoặc đã bị thu hồi"
}
}{
"error": {
"code": 401,
"message": "API key không hợp lệ hoặc đã bị thu hồi"
}
}Authorizations
bearerAuthapiKeyAuth
Authorization: Bearer ak_live_…
Body
application/json
⌘I