Bạn Tìm Gì Hôm Nay ...?
Tất cả đều có chỉ trong 1 nốt nhạc !
Nếu cần hỗ trợ chi tiết gọi 1900 9477
Nhằm giúp Quý khách hàng thuận lợi trong khi sử dụng dịch vụ SMS Brandname, PA Việt Nam cung cấp Quý khách hàng API mẫu. Toàn bộ API này Quý khách hàng sẽ thấy trên Web Tool của PA Việt Nam.
*** Quý khách lưu ý, token trong code mẫu là token mẫu (không sử dụng được); Quý khách hàng sẽ có token chính xác tương ứng Brandname của Quý khách hàng khi Quý khách tạo ra token trên Web Tool.
Ghi chú:
Code API PHP:
Gửi ngay lập tức:
<?php
$data_request = [
‘action’ => ‘create’,
‘token’ => ‘ae7ed67dd46754bd30xxxxx’,
‘title’ => ‘Demo API create campaign’,
‘type’ => ‘cus’,
‘couponGroup’ => ”,
‘scheduleDate’ => ”,
‘message’ => ‘Day la tin nhan kiem thu API’,
‘brandName’ => ‘PAVIETNAM’,
‘check_blacklist’ => ‘1’, // 1: check kho blacklist, 0: bỏ qua.
‘phones’ => ‘0901234567’,
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ‘https://domain/api/’);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data_request));
$result = curl_exec($ch);
echo $result;
?>
Gửi theo thời gian cụ thể:
<?php
$data_request = [
‘action’ => ‘create’,
‘token’ => ‘ae7ed67dd46754bd30xxxxx’,
‘title’ => ‘Demo API create campaign’,
‘type’ => ‘cus’,
‘couponGroup’ => ”,
‘scheduleDate’ => ’10-10-2018 23:28′,
‘message’ => ‘Day la tin nhan kiem thu API’,
‘brandName’ => ‘PAVIETNAM’,
‘check_blacklist’ => ‘1’, // 1: check kho blacklist, 0: bỏ qua.
‘phones’ => ‘0901234567’,
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ‘https://domain/api/’);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data_request));
$result = curl_exec($ch);
echo $result;
?>
Code API JAVA:
Gửi ngay lập tức:
package APISampleJAVA
import …
public class APISampleJAVA {
private final String USER_AGENT = “Mozilla/5.0”;
public static void main(String[] args) throws Exception {
APISampleJAVA request = new APISampleJAVA();
String url = “https://domain/api/”;
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(“action”, “create”);
parameters.put(“token”, “ae7ed67dd46754bd30xxxxx”);
parameters.put(“title”, “Demo API create campaign”);
parameters.put(“type”, “cus”);
parameters.put(“couponGroup”, “”);
parameters.put(“scheduleDate”, “”);
parameters.put(“message”, “Day la tin nhan kiem thu API”);
parameters.put(“brandName”, “PAVIETNAM”);
parameters.put(“check_blacklist”, “1”); // update blacklist 12/2020; 1: check kho blacklist, 0: bỏ qua.
parameters.put(“phones”, “0901234567”);
StringBuffer response = request.SendGET(url, parameters);
System.out.println(response);
}
private StringBuffer SendPOST(String url, Map<String, String> parameters) throws Exception {
String urlParameters = “”;
TreeMap<String, String> params = new TreeMap<String, String>(parameters);
for (Map.Entry<String, String> param : params.entrySet()) {
if (urlParameters.length() > 0) {
urlParameters += “&”;
}
urlParameters += param.getKey() + “=” + urlEncode(param.getValue());
}
URL obj = new URL(url);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
con.setRequestMethod(“POST”);
con.setRequestProperty(“User-Agent”, USER_AGENT);
con.setRequestProperty(“Accept-Language”, “en-US,en;q=0.5”);
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream())
);
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
return response;
}
private String urlEncode(String value) throws Exception {
return URLEncoder.encode(value, “UTF-8”);
}
}
Gửi ngay theo thời gian cụ thể:
package APISampleJAVA
import …
public class APISampleJAVA {
private final String USER_AGENT = “Mozilla/5.0”;
public static void main(String[] args) throws Exception {
APISampleJAVA request = new APISampleJAVA();
String url = “https://domain/api/”;
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(“action”, “create”);
parameters.put(“token”, “ae7ed67dd46754bd30xxxxx”);
parameters.put(“title”, “Demo API create campaign”);
parameters.put(“type”, “cus”);
parameters.put(“couponGroup”, “”);
parameters.put(“scheduleDate”, “10-10-2018 23:28”);
parameters.put(“message”, “Day la tin nhan kiem thu API”);
parameters.put(“brandName”, “PAVIETNAM”);
parameters.put(“check_blacklist”, “0”); // update blacklist 12/2020; 1: check kho blacklist, 0: bỏ qua.
parameters.put(“phones”, “0901234567”);
StringBuffer response = request.SendGET(url, parameters);
System.out.println(response);
}
private StringBuffer SendPOST(String url, Map<String, String> parameters) throws Exception {
String urlParameters = “”;
TreeMap<String, String> params = new TreeMap<String, String>(parameters);
for (Map.Entry<String, String> param : params.entrySet()) {
if (urlParameters.length() > 0) {
urlParameters += “&”;
}
urlParameters += param.getKey() + “=” + urlEncode(param.getValue());
}
URL obj = new URL(url);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
con.setRequestMethod(“POST”);
con.setRequestProperty(“User-Agent”, USER_AGENT);
con.setRequestProperty(“Accept-Language”, “en-US,en;q=0.5”);
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream())
);
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
return response;
}
private String urlEncode(String value) throws Exception {
return URLEncoder.encode(value, “UTF-8”);
}
}
Gửi Quảng cáo cần theo thời gian cụ thể theo quy định của nhà mạng và được PA Việt Nam chú thích trên Web Tool khi Quý khách sử dụng dịch vụ.
Code API PHP:
<?php
$data_request = [
‘action’ => ‘create’,
‘token’ => ‘ae7ed67dd46754bd30xxxxx’,
‘title’ => ‘Demo API create campaign’,
‘type’ => ‘marketing’,
‘scheduleDate’ => ’10-10-2018 23:28′,
‘message’ => ‘Day la tin nhan kiem thu API’,
‘brandName’ => ‘PAVIETNAM’,
‘check_blacklist’ => ‘1’, // 1: check kho blacklist, 0: bỏ qua.
‘phones’ => array(‘0901234567’, ‘0901234567’, ‘0901234567’, ‘0901234567’, ‘0901234567’, ‘0901234567’, ‘0901234567’, ‘0901234567’, ‘0901234567’, ‘0901234567’, ‘0901234567’, ‘0901234567’, ‘0901234567’), // tối thiểu 150 tin nhắn khi gửi Quảng cáo
‘quota’ => ‘20000’, // Message có độ dài 200 kí tự (tương đương 2 tin nhắn), muốn gửi tin tới 1 List 1000 số điện thoại trong chiến dịch, vậy Quota tối thiểu cần là: 1000 x 2 = 2000
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ‘https://domain/api/’);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data_request));
$result = curl_exec($ch);
echo $result;
?>
Code API JAVA
package APISampleJAVA
import …
public class APISampleJAVA {
private final String USER_AGENT = “Mozilla/5.0”;
public static void main(String[] args) throws Exception {
APISampleJAVA request = new APISampleJAVA();
String url = “https://domain/api/”;
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(“action”, “create”);
parameters.put(“token”, “ae7ed67dd46754bd30xxxxx”);
parameters.put(“title”, “Demo API create campaign”);
parameters.put(“type”, “marketing”);
parameters.put(“scheduleDate”, “”);
parameters.put(“message”, “Day la tin nhan kiem thu API”);
parameters.put(“brandName”, “PAVIETNAM”);
parameters.put(“check_blacklist”, “1”); // update blacklist 12/2020; 1: check kho blacklist, 0: bỏ qua.
parameters.put(“quota”, “20000”); // Message có độ dài 200 kí tự (tương đương 2 tin nhắn), muốn gửi tin tới 1 List 1000 số điện thoại trong chiến dịch, vậy Quota tối thiểu cần là: 1000 x 2 = 2000
parameters.put(“phones[]”, “0901234567”);
parameters.put(“phones[]”, “0901234567”);
parameters.put(“phones[]”, “0901234567”);
parameters.put(“phones[]”, “0901234567”);
parameters.put(“phones[]”, “0901234567”);
parameters.put(“phones[]”, “0901234567”);
parameters.put(“phones[]”, “0901234567”);
parameters.put(“phones[]”, “0901234567”);
parameters.put(“phones[]”, “0901234567”);
parameters.put(“phones[]”, “0901234567”);
parameters.put(“phones[]”, “0901234567”);
parameters.put(“phones[]”, “0901234567”);
parameters.put(“phones[]”, “0901234567”);
StringBuffer response = request.SendGET(url, parameters);
System.out.println(response);
}
private StringBuffer SendPOST(String url, Map<String, String> parameters) throws Exception {
String urlParameters = “”;
TreeMap<String, String> params = new TreeMap<String, String>(parameters);
for (Map.Entry<String, String> param : params.entrySet()) {
if (urlParameters.length() > 0) {
urlParameters += “&”;
}
urlParameters += param.getKey() + “=” + urlEncode(param.getValue());
}
URL obj = new URL(url);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
con.setRequestMethod(“POST”);
con.setRequestProperty(“User-Agent”, USER_AGENT);
con.setRequestProperty(“Accept-Language”, “en-US,en;q=0.5”);
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream())
);
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
return response;
}
private String urlEncode(String value) throws Exception {
return URLEncoder.encode(value, “UTF-8”);
}
}
* Chú ý: Quý khách cũng cần phải gửi tối thiếu 150 số và khai báo mảng:
parameters.put(“phones[]”, “0901234567”);
PA Việt Nam