curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"autoResponseActive": true, "autoResponseWaitSeconds": 30, "autoResponseMessage": "Howdy!"' \
-X POST https://api.ayrshare.com/api/messages/autoresponse
const url = 'https://api.ayrshare.com/api/messages/autoresponse';
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'
},
body: JSON.stringify({
'autoResponseActive': true,
'autoResponseWaitSeconds': 30,
'autoResponseMessage': 'Howdy!'
})
};
fetch(url, options)
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import json
import requests
url = 'https://api.ayrshare.com/api/messages/autoresponse'
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'
}
data = {
'autoResponseActive': True,
'autoResponseWaitSeconds': 30,
'autoResponseMessage': 'Howdy!'
}
response = requests.post(url, headers=headers, data=json.dumps(data))
try:
response.raise_for_status()
data = response.json()
print(data)
except requests.exceptions.RequestException as e:
print('Error:', e)
<?php
$url = 'https://api.ayrshare.com/api/messages/autoresponse';
$headers = [
'Content-Type: application/json',
'Authorization: Bearer API_KEY'
];
$data = [
'autoResponseActive' => true,
'autoResponseWaitSeconds' => 30,
'autoResponseMessage' => 'Howdy!'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error: ' . curl_error($ch);
} else {
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode >= 400) {
echo 'Error: HTTP ' . $httpCode;
} else {
$data = json_decode($response, true);
print_r($data);
}
}
curl_close($ch);
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
string url = "https://api.ayrshare.com/api/messages/autoresponse";
var headers = new Dictionary<string, string>
{
{"Content-Type", "application/json"},
{"Authorization", "Bearer API_KEY"}
};
var data = new Dictionary<string, object>
{
{"autoResponseActive", true},
{"autoResponseWaitSeconds", 30},
{"autoResponseMessage", "Howdy!"}
};
using (var client = new HttpClient())
{
var jsonData = JsonSerializer.Serialize(data);
var content = new StringContent(jsonData, Encoding.UTF8, "application/json");
foreach (var header in headers)
{
client.DefaultRequestHeaders.Add(header.Key, header.Value);
}
var response = await client.PostAsync(url, content);
try
{
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
var responseData = JsonSerializer.Deserialize<Dictionary<string, object>>(responseBody);
Console.WriteLine(JsonSerializer.Serialize(responseData, new JsonSerializerOptions { WriteIndented = true }));
}
catch (HttpRequestException e)
{
Console.WriteLine($"Error: {e.Message}");
}
}
}
}
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.HashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) {
String url = "https://api.ayrshare.com/api/messages/autoresponse";
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
headers.put("Authorization", "Bearer API_KEY");
Map<String, Object> data = new HashMap<>();
data.put("autoResponseActive", true);
data.put("autoResponseWaitSeconds", 30);
data.put("autoResponseMessage", "Howdy!");
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.headers(headers.entrySet().stream()
.map(entry -> entry.getKey() + ": " + entry.getValue())
.toArray(String[]::new))
.POST(HttpRequest.BodyPublishers.ofString(getJsonString(data)))
.build();
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 400) {
System.out.println("Error: HTTP " + response.statusCode());
} else {
System.out.println(response.body());
}
} catch (IOException | InterruptedException e) {
System.out.println("Error: " + e.getMessage());
}
}
private static String getJsonString(Map<String, Object> data) {
StringBuilder jsonBuilder = new StringBuilder();
jsonBuilder.append("{");
for (Map.Entry<String, Object> entry : data.entrySet()) {
jsonBuilder.append("\"").append(entry.getKey()).append("\":");
if (entry.getValue() instanceof String) {
jsonBuilder.append("\"").append(entry.getValue()).append("\"");
} else {
jsonBuilder.append(entry.getValue());
}
jsonBuilder.append(",");
}
if (jsonBuilder.length() > 1) {
jsonBuilder.setLength(jsonBuilder.length() - 1);
}
jsonBuilder.append("}");
return jsonBuilder.toString();
}
}
{
"status": "success",
"updated": {
"autoResponseActive": true,
"autoResponseMessage": "Howdy!",
"autoResponseWaitSeconds": 30
}
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. .../ayrshare.com/rest-api/endpoints"
}
Messages
Đặt Phản hồi Tự động
Tự động gửi các phản hồi tin nhắn tự động
POST
/
messages
/
autoresponse
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"autoResponseActive": true, "autoResponseWaitSeconds": 30, "autoResponseMessage": "Howdy!"' \
-X POST https://api.ayrshare.com/api/messages/autoresponse
const url = 'https://api.ayrshare.com/api/messages/autoresponse';
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'
},
body: JSON.stringify({
'autoResponseActive': true,
'autoResponseWaitSeconds': 30,
'autoResponseMessage': 'Howdy!'
})
};
fetch(url, options)
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import json
import requests
url = 'https://api.ayrshare.com/api/messages/autoresponse'
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'
}
data = {
'autoResponseActive': True,
'autoResponseWaitSeconds': 30,
'autoResponseMessage': 'Howdy!'
}
response = requests.post(url, headers=headers, data=json.dumps(data))
try:
response.raise_for_status()
data = response.json()
print(data)
except requests.exceptions.RequestException as e:
print('Error:', e)
<?php
$url = 'https://api.ayrshare.com/api/messages/autoresponse';
$headers = [
'Content-Type: application/json',
'Authorization: Bearer API_KEY'
];
$data = [
'autoResponseActive' => true,
'autoResponseWaitSeconds' => 30,
'autoResponseMessage' => 'Howdy!'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error: ' . curl_error($ch);
} else {
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode >= 400) {
echo 'Error: HTTP ' . $httpCode;
} else {
$data = json_decode($response, true);
print_r($data);
}
}
curl_close($ch);
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
string url = "https://api.ayrshare.com/api/messages/autoresponse";
var headers = new Dictionary<string, string>
{
{"Content-Type", "application/json"},
{"Authorization", "Bearer API_KEY"}
};
var data = new Dictionary<string, object>
{
{"autoResponseActive", true},
{"autoResponseWaitSeconds", 30},
{"autoResponseMessage", "Howdy!"}
};
using (var client = new HttpClient())
{
var jsonData = JsonSerializer.Serialize(data);
var content = new StringContent(jsonData, Encoding.UTF8, "application/json");
foreach (var header in headers)
{
client.DefaultRequestHeaders.Add(header.Key, header.Value);
}
var response = await client.PostAsync(url, content);
try
{
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
var responseData = JsonSerializer.Deserialize<Dictionary<string, object>>(responseBody);
Console.WriteLine(JsonSerializer.Serialize(responseData, new JsonSerializerOptions { WriteIndented = true }));
}
catch (HttpRequestException e)
{
Console.WriteLine($"Error: {e.Message}");
}
}
}
}
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.HashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) {
String url = "https://api.ayrshare.com/api/messages/autoresponse";
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
headers.put("Authorization", "Bearer API_KEY");
Map<String, Object> data = new HashMap<>();
data.put("autoResponseActive", true);
data.put("autoResponseWaitSeconds", 30);
data.put("autoResponseMessage", "Howdy!");
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.headers(headers.entrySet().stream()
.map(entry -> entry.getKey() + ": " + entry.getValue())
.toArray(String[]::new))
.POST(HttpRequest.BodyPublishers.ofString(getJsonString(data)))
.build();
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 400) {
System.out.println("Error: HTTP " + response.statusCode());
} else {
System.out.println(response.body());
}
} catch (IOException | InterruptedException e) {
System.out.println("Error: " + e.getMessage());
}
}
private static String getJsonString(Map<String, Object> data) {
StringBuilder jsonBuilder = new StringBuilder();
jsonBuilder.append("{");
for (Map.Entry<String, Object> entry : data.entrySet()) {
jsonBuilder.append("\"").append(entry.getKey()).append("\":");
if (entry.getValue() instanceof String) {
jsonBuilder.append("\"").append(entry.getValue()).append("\"");
} else {
jsonBuilder.append(entry.getValue());
}
jsonBuilder.append(",");
}
if (jsonBuilder.length() > 1) {
jsonBuilder.setLength(jsonBuilder.length() - 1);
}
jsonBuilder.append("}");
return jsonBuilder.toString();
}
}
{
"status": "success",
"updated": {
"autoResponseActive": true,
"autoResponseMessage": "Howdy!",
"autoResponseWaitSeconds": 30
}
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. .../ayrshare.com/rest-api/endpoints"
}
Tự động gửi các phản hồi tin nhắn tự động đến người liên lạc. Điều này hữu ích nếu bàn hỗ trợ dịch vụ khách hàng của bạn hiện không khả dụng.
Nếu được kích hoạt, phản hồi tự động sẽ được sử dụng cho tất cả các mạng xã hội cho một User Profile nhất định.
Tham số Header
Tham số Body
Liệu phản hồi tự động có đang hoạt động hay không.
Số giây chờ trước khi gửi phản hồi tự động lại cho người liên lạc. Mặc định là 86.400 giây (24 giờ).
Tin nhắn phản hồi tự động.Mặc định: “Thank you for contacting us. A customer care agent will get back to you soon.”Gửi một chuỗi rỗng "" để đặt lại tin nhắn về mặc định.
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"autoResponseActive": true, "autoResponseWaitSeconds": 30, "autoResponseMessage": "Howdy!"' \
-X POST https://api.ayrshare.com/api/messages/autoresponse
const url = 'https://api.ayrshare.com/api/messages/autoresponse';
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'
},
body: JSON.stringify({
'autoResponseActive': true,
'autoResponseWaitSeconds': 30,
'autoResponseMessage': 'Howdy!'
})
};
fetch(url, options)
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import json
import requests
url = 'https://api.ayrshare.com/api/messages/autoresponse'
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'
}
data = {
'autoResponseActive': True,
'autoResponseWaitSeconds': 30,
'autoResponseMessage': 'Howdy!'
}
response = requests.post(url, headers=headers, data=json.dumps(data))
try:
response.raise_for_status()
data = response.json()
print(data)
except requests.exceptions.RequestException as e:
print('Error:', e)
<?php
$url = 'https://api.ayrshare.com/api/messages/autoresponse';
$headers = [
'Content-Type: application/json',
'Authorization: Bearer API_KEY'
];
$data = [
'autoResponseActive' => true,
'autoResponseWaitSeconds' => 30,
'autoResponseMessage' => 'Howdy!'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error: ' . curl_error($ch);
} else {
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode >= 400) {
echo 'Error: HTTP ' . $httpCode;
} else {
$data = json_decode($response, true);
print_r($data);
}
}
curl_close($ch);
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
string url = "https://api.ayrshare.com/api/messages/autoresponse";
var headers = new Dictionary<string, string>
{
{"Content-Type", "application/json"},
{"Authorization", "Bearer API_KEY"}
};
var data = new Dictionary<string, object>
{
{"autoResponseActive", true},
{"autoResponseWaitSeconds", 30},
{"autoResponseMessage", "Howdy!"}
};
using (var client = new HttpClient())
{
var jsonData = JsonSerializer.Serialize(data);
var content = new StringContent(jsonData, Encoding.UTF8, "application/json");
foreach (var header in headers)
{
client.DefaultRequestHeaders.Add(header.Key, header.Value);
}
var response = await client.PostAsync(url, content);
try
{
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
var responseData = JsonSerializer.Deserialize<Dictionary<string, object>>(responseBody);
Console.WriteLine(JsonSerializer.Serialize(responseData, new JsonSerializerOptions { WriteIndented = true }));
}
catch (HttpRequestException e)
{
Console.WriteLine($"Error: {e.Message}");
}
}
}
}
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.HashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) {
String url = "https://api.ayrshare.com/api/messages/autoresponse";
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
headers.put("Authorization", "Bearer API_KEY");
Map<String, Object> data = new HashMap<>();
data.put("autoResponseActive", true);
data.put("autoResponseWaitSeconds", 30);
data.put("autoResponseMessage", "Howdy!");
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.headers(headers.entrySet().stream()
.map(entry -> entry.getKey() + ": " + entry.getValue())
.toArray(String[]::new))
.POST(HttpRequest.BodyPublishers.ofString(getJsonString(data)))
.build();
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 400) {
System.out.println("Error: HTTP " + response.statusCode());
} else {
System.out.println(response.body());
}
} catch (IOException | InterruptedException e) {
System.out.println("Error: " + e.getMessage());
}
}
private static String getJsonString(Map<String, Object> data) {
StringBuilder jsonBuilder = new StringBuilder();
jsonBuilder.append("{");
for (Map.Entry<String, Object> entry : data.entrySet()) {
jsonBuilder.append("\"").append(entry.getKey()).append("\":");
if (entry.getValue() instanceof String) {
jsonBuilder.append("\"").append(entry.getValue()).append("\"");
} else {
jsonBuilder.append(entry.getValue());
}
jsonBuilder.append(",");
}
if (jsonBuilder.length() > 1) {
jsonBuilder.setLength(jsonBuilder.length() - 1);
}
jsonBuilder.append("}");
return jsonBuilder.toString();
}
}
{
"status": "success",
"updated": {
"autoResponseActive": true,
"autoResponseMessage": "Howdy!",
"autoResponseWaitSeconds": 30
}
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. .../ayrshare.com/rest-api/endpoints"
}
⌘I
