curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"message": "What's up!", "recipientId": "283j839222"} \
-X POST https://api.ayrshare.com/api/messages/instagram
const apiKey = 'API_KEY';
const url = 'https://api.ayrshare.com/api/messages/instagram';
const data = {
message: "What's up!",
recipientId: '283j839222',
};
const headers = {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json',
};
fetch(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(data),
})
.then(response => response.json())
.then(data => {
console.log('Response:', data);
})
.catch(error => {
console.error('Error:', error);
});
import requests
api_key = 'API_KEY'
url = 'https://api.ayrshare.com/api/messages/instagram'
data = {
'message': "What's up!",
'recipientId': '283j839222',
}
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json',
}
response = requests.post(url, json=data, headers=headers)
print('Response:', response.json())
<?php
$apiKey = 'API_KEY';
$url = 'https://api.ayrshare.com/api/messages/instagram';
$data = [
'message' => "What's up!",
'recipientId' => '283j839222',
];
$headers = [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if ($response === false) {
$error = curl_error($ch);
echo 'Error: ' . $error;
} else {
$responseData = json_decode($response, true);
print_r($responseData);
}
curl_close($ch);
?>
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
string apiKey = "API_KEY";
string url = "https://api.ayrshare.com/api/messages/instagram";
var data = new
{
message = "What's up!",
recipientId = "283j839222"
};
var jsonData = JsonSerializer.Serialize(data);
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var content = new StringContent(jsonData, Encoding.UTF8, "application/json");
try
{
var response = await client.PostAsync(url, content);
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
var responseData = JsonSerializer.Deserialize<dynamic>(responseBody);
Console.WriteLine("Response:");
Console.WriteLine(responseData);
}
catch (HttpRequestException ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
String apiKey = "API_KEY";
String url = "https://api.ayrshare.com/api/messages/instagram";
String data = "{\"message\": \"What's up!\", \"recipientId\": \"283j839222\"}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(data))
.build();
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
String responseBody = response.body();
System.out.println("Response:");
System.out.println(responseBody);
} else {
System.out.println("Request failed. Status code: " + response.statusCode());
}
} catch (IOException | InterruptedException e) {
System.out.println("Error: " + e.getMessage());
}
}
}
{ // single text message
"status": "success",
"recipientId": "72706337063589124",
"messageId": "aWdfZAG1faXRlbToxOkl",
"message": "What is up?"
}
{
// single text message
"action": "messages",
"status": "error",
"code": 363,
"message": "The recipient ID was not found. Please confirm the recipient ID is correct."
}
{
// single image
"status": "success",
"recipientId": "761943",
"messageId": "m_EgvfBrgjaM",
"type": "image",
"mediaUrl": "https://img.ayrshare.com/012/gb.jpg"
}
{
// text and image message
"action": "send",
"status": "error",
"code": 337,
"message": "Error sending message.",
"messages": [
{
"recipientId": "727063370635",
"messageId": "aWdfZAG1faXRlbT",
"message": "What a great day"
},
{
"action": "messages",
"status": "error",
"code": 365,
"message": "An error occurred sending the message attachment. Please verify the attachment is still available and try again."
}
]
}
Messages
Enviar mensagem
Envie uma mensagem direta para um destinatário
POST
/
messages
/
:platform
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"message": "What's up!", "recipientId": "283j839222"} \
-X POST https://api.ayrshare.com/api/messages/instagram
const apiKey = 'API_KEY';
const url = 'https://api.ayrshare.com/api/messages/instagram';
const data = {
message: "What's up!",
recipientId: '283j839222',
};
const headers = {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json',
};
fetch(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(data),
})
.then(response => response.json())
.then(data => {
console.log('Response:', data);
})
.catch(error => {
console.error('Error:', error);
});
import requests
api_key = 'API_KEY'
url = 'https://api.ayrshare.com/api/messages/instagram'
data = {
'message': "What's up!",
'recipientId': '283j839222',
}
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json',
}
response = requests.post(url, json=data, headers=headers)
print('Response:', response.json())
<?php
$apiKey = 'API_KEY';
$url = 'https://api.ayrshare.com/api/messages/instagram';
$data = [
'message' => "What's up!",
'recipientId' => '283j839222',
];
$headers = [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if ($response === false) {
$error = curl_error($ch);
echo 'Error: ' . $error;
} else {
$responseData = json_decode($response, true);
print_r($responseData);
}
curl_close($ch);
?>
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
string apiKey = "API_KEY";
string url = "https://api.ayrshare.com/api/messages/instagram";
var data = new
{
message = "What's up!",
recipientId = "283j839222"
};
var jsonData = JsonSerializer.Serialize(data);
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var content = new StringContent(jsonData, Encoding.UTF8, "application/json");
try
{
var response = await client.PostAsync(url, content);
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
var responseData = JsonSerializer.Deserialize<dynamic>(responseBody);
Console.WriteLine("Response:");
Console.WriteLine(responseData);
}
catch (HttpRequestException ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
String apiKey = "API_KEY";
String url = "https://api.ayrshare.com/api/messages/instagram";
String data = "{\"message\": \"What's up!\", \"recipientId\": \"283j839222\"}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(data))
.build();
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
String responseBody = response.body();
System.out.println("Response:");
System.out.println(responseBody);
} else {
System.out.println("Request failed. Status code: " + response.statusCode());
}
} catch (IOException | InterruptedException e) {
System.out.println("Error: " + e.getMessage());
}
}
}
{ // single text message
"status": "success",
"recipientId": "72706337063589124",
"messageId": "aWdfZAG1faXRlbToxOkl",
"message": "What is up?"
}
{
// single text message
"action": "messages",
"status": "error",
"code": 363,
"message": "The recipient ID was not found. Please confirm the recipient ID is correct."
}
{
// single image
"status": "success",
"recipientId": "761943",
"messageId": "m_EgvfBrgjaM",
"type": "image",
"mediaUrl": "https://img.ayrshare.com/012/gb.jpg"
}
{
// text and image message
"action": "send",
"status": "error",
"code": 337,
"message": "Error sending message.",
"messages": [
{
"recipientId": "727063370635",
"messageId": "aWdfZAG1faXRlbT",
"message": "What a great day"
},
{
"action": "messages",
"status": "error",
"code": 365,
"message": "An error occurred sending the message attachment. Please verify the attachment is still available and try again."
}
]
}
Envie uma nova mensagem direta para um destinatário.
Preços e limites: cada User Profile pode ter até 1.000 conversas
ativas por ciclo de cobrança em todas as redes sociais. O preço depende
do seu plano: os planos Premium pagam um add-on fixo de US49porme^s∗∗,enquantoosplanos∗∗Launch∗∗e∗∗Business∗∗sa~ocobradosa∗∗US 0,09 por conversa
ativa. Uma conversa é contada como
ativa quando você envia uma mensagem para um destinatário durante o ciclo de cobrança;
mensagens recebidas por si só não contam. O número de mensagens dentro de uma
conversa ativa é ilimitado.
- Você pode enviar um emoji como parte do texto da
message. - As
mediaUrlsdo Facebook e Instagram devem terminar com uma extensão conhecida. Incluir parâmetros de query fará com que a URL da mídia falhe.
Parâmetros do header
Parâmetros de path
A plataforma para enviar a mensagem:
facebook, instagram, twitterParâmetros do body
O ID do destinatário da mensagem.
A mensagem a ser enviada ao destinatário.
- A mensagem para Facebook e Instagram pode ser uma string vazia ou não ser incluída se
mediaUrlsfor fornecido. - O X exige uma mensagem com pelo menos um caractere, mesmo que
mediaUrlsseja fornecido.
Array de URLs de mídia para anexar imagens, um vídeo ou uma mensagem de voz.
- URLs de itens de mídia devem terminar com a extensão do arquivo, sem parâmetros adicionais anexados.
- Facebook e Instagram suportam múltiplas URLs de mídia.
- O X aceita apenas uma única URL de mídia.
- Mensagens de voz são suportadas no Facebook e Instagram como arquivos
aacouwav.
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"message": "What's up!", "recipientId": "283j839222"} \
-X POST https://api.ayrshare.com/api/messages/instagram
const apiKey = 'API_KEY';
const url = 'https://api.ayrshare.com/api/messages/instagram';
const data = {
message: "What's up!",
recipientId: '283j839222',
};
const headers = {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json',
};
fetch(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(data),
})
.then(response => response.json())
.then(data => {
console.log('Response:', data);
})
.catch(error => {
console.error('Error:', error);
});
import requests
api_key = 'API_KEY'
url = 'https://api.ayrshare.com/api/messages/instagram'
data = {
'message': "What's up!",
'recipientId': '283j839222',
}
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json',
}
response = requests.post(url, json=data, headers=headers)
print('Response:', response.json())
<?php
$apiKey = 'API_KEY';
$url = 'https://api.ayrshare.com/api/messages/instagram';
$data = [
'message' => "What's up!",
'recipientId' => '283j839222',
];
$headers = [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if ($response === false) {
$error = curl_error($ch);
echo 'Error: ' . $error;
} else {
$responseData = json_decode($response, true);
print_r($responseData);
}
curl_close($ch);
?>
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
string apiKey = "API_KEY";
string url = "https://api.ayrshare.com/api/messages/instagram";
var data = new
{
message = "What's up!",
recipientId = "283j839222"
};
var jsonData = JsonSerializer.Serialize(data);
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var content = new StringContent(jsonData, Encoding.UTF8, "application/json");
try
{
var response = await client.PostAsync(url, content);
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
var responseData = JsonSerializer.Deserialize<dynamic>(responseBody);
Console.WriteLine("Response:");
Console.WriteLine(responseData);
}
catch (HttpRequestException ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
String apiKey = "API_KEY";
String url = "https://api.ayrshare.com/api/messages/instagram";
String data = "{\"message\": \"What's up!\", \"recipientId\": \"283j839222\"}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(data))
.build();
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
String responseBody = response.body();
System.out.println("Response:");
System.out.println(responseBody);
} else {
System.out.println("Request failed. Status code: " + response.statusCode());
}
} catch (IOException | InterruptedException e) {
System.out.println("Error: " + e.getMessage());
}
}
}
{ // single text message
"status": "success",
"recipientId": "72706337063589124",
"messageId": "aWdfZAG1faXRlbToxOkl",
"message": "What is up?"
}
{
// single text message
"action": "messages",
"status": "error",
"code": 363,
"message": "The recipient ID was not found. Please confirm the recipient ID is correct."
}
{
// single image
"status": "success",
"recipientId": "761943",
"messageId": "m_EgvfBrgjaM",
"type": "image",
"mediaUrl": "https://img.ayrshare.com/012/gb.jpg"
}
{
// text and image message
"action": "send",
"status": "error",
"code": 337,
"message": "Error sending message.",
"messages": [
{
"recipientId": "727063370635",
"messageId": "aWdfZAG1faXRlbT",
"message": "What a great day"
},
{
"action": "messages",
"status": "error",
"code": 365,
"message": "An error occurred sending the message attachment. Please verify the attachment is still available and try again."
}
]
}
⌘I
