curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"title": "ACME Profile"}' \
-X POST https://api.ayrshare.com/api/profiles
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/profiles", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
title: "ACME Profile", // required
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {'title': 'ACME Profile'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.post('https://api.ayrshare.com/api/profiles',
json=payload,
headers=headers)
print(r.json())
<?php
require 'vendor/autoload.php'; // Composer auto-loader using Guzzle. See .../guzzlephp.org/en/stable/overview.html
$client = new GuzzleHttp\Client();
$res = $client->request(
'POST',
'https://api.ayrshare.com/api/profiles',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'title' => ['ACME Profile'],
]
);
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
package main
import (
"bytes"
"encoding/json"
"log"
"net/http"
)
func main() {
message := map[string]interface{}{
"title": "ACME Profile"
}
bytesRepresentation, err := json.Marshal(message)
if err != nil {
log.Fatalln(err)
}
req, _ := http.NewRequest("POST", "https://api.ayrshare.com/api/profiles",
bytes.NewBuffer(bytesRepresentation))
req.Header.Add("Content-Type", "application/json; charset=UTF-8")
req.Header.Add("Authorization", "Bearer API_KEY")
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal("Error:", err)
}
res.Body.Close()
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace CreateProfilePOSTRequest_csharp
{
class CreateProfile
{
static async Task Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://api.ayrshare.com/api/profiles";
string json = "{\"title\": \"ACME Profile\"}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);
try
{
var content = new StringContent(json, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(url, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (HttpRequestException e)
{
Console.WriteLine($"Error: {e.Message}");
}
}
}
}
}
{
"status": "success",
"title": "Digg It",
"refId": "140b8709bd6ade099b242d895e268fb886130c53",
"profileKey": "7TVRLEZ-24A43C0-NJW0Z82-F11984N",
"messagingActive": true // true if messaging for this user profile is active
}
{
"action": "create",
"status": "error",
"code": 146,
"message": "Profile title already exists."
}
Profiles
创建 User Profile
在你的 Primary Profile 下创建一个新的 User Profile。
POST
/
profiles
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"title": "ACME Profile"}' \
-X POST https://api.ayrshare.com/api/profiles
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/profiles", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
title: "ACME Profile", // required
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {'title': 'ACME Profile'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.post('https://api.ayrshare.com/api/profiles',
json=payload,
headers=headers)
print(r.json())
<?php
require 'vendor/autoload.php'; // Composer auto-loader using Guzzle. See .../guzzlephp.org/en/stable/overview.html
$client = new GuzzleHttp\Client();
$res = $client->request(
'POST',
'https://api.ayrshare.com/api/profiles',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'title' => ['ACME Profile'],
]
);
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
package main
import (
"bytes"
"encoding/json"
"log"
"net/http"
)
func main() {
message := map[string]interface{}{
"title": "ACME Profile"
}
bytesRepresentation, err := json.Marshal(message)
if err != nil {
log.Fatalln(err)
}
req, _ := http.NewRequest("POST", "https://api.ayrshare.com/api/profiles",
bytes.NewBuffer(bytesRepresentation))
req.Header.Add("Content-Type", "application/json; charset=UTF-8")
req.Header.Add("Authorization", "Bearer API_KEY")
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal("Error:", err)
}
res.Body.Close()
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace CreateProfilePOSTRequest_csharp
{
class CreateProfile
{
static async Task Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://api.ayrshare.com/api/profiles";
string json = "{\"title\": \"ACME Profile\"}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);
try
{
var content = new StringContent(json, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(url, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (HttpRequestException e)
{
Console.WriteLine($"Error: {e.Message}");
}
}
}
}
}
{
"status": "success",
"title": "Digg It",
"refId": "140b8709bd6ade099b242d895e268fb886130c53",
"profileKey": "7TVRLEZ-24A43C0-NJW0Z82-F11984N",
"messagingActive": true // true if messaging for this user profile is active
}
{
"action": "create",
"status": "error",
"code": 146,
"message": "Profile title already exists."
}
在你的 Primary Profile 下创建一个新的 profile。User Profile 创建成功后,API 响应将包含与新创建的 profile 关联的 Profile Key。请将该 Profile Key 安全地存储在你的系统中,后续以该用户身份调用 API 时会用到它。
请注意,出于安全考虑,Profile Key 仅在以下两种情况下会被返回:
- User Profile 创建时:创建新的 User Profile 时。
- 在 Ayrshare 控制台中:你可以在 Ayrshare 控制台中查看每个 profile 的 Profile Key。切换到该 User Profile,然后进入 Profile Key 页面。
管理社交网络
使用 disableSocial 字段来管理(添加/移除)展示的社交网络。更多信息请参见管理社交账户。管理活跃的 User Profile
请参见此处,查看关于管理活跃 User Profile 的建议。重要的安全注意事项
- 请勿公开分享 Profile Key,或将其暴露在客户端代码或公共代码仓库中。
- Profile Key 是用于对 User Profile 访问进行身份验证与授权的敏感凭据。
- 务必将 Profile Key 安全地存储在你的系统中,并设置适当的访问控制,以维护用户数据的完整性与保密性。
- 出于安全考虑,无法通过 API 再次获取 Profile Key。不过你可以从控制台中获取。
- 同时也应保存
refId,以便将 profile 与端点返回结果关联起来。
Header 参数
Body 参数
新 profile 的标题。必须唯一。该标题将显示在社交账户关联页面上。
设为 true 可为该 user profile 启用私信 (DM) 功能。必须先在你的 Ayrshare 账户中启用私信功能。
在社交账户关联页面上隐藏顶部标题栏。
仅在该 user profile 的社交账户关联页面上隐藏公司 logo。其他 profile 上的账户级 logo 不受影响。适用于对特定合作伙伴 profile 进行白标处理,同时保留其余 profile 的品牌标识。
更改社交账户关联页面的标题栏。若未设置,则显示:“Social Accounts for “title"",其中 “title” 为 profile 的标题。
为该 user profile 禁用的社交网络数组。Primary Profile 上禁用的社交网络列表优先生效。可用网络:
bluesky、facebook、gmb、instagram、linkedin、pinterest、reddit、snapchat、telegram、threads、tiktok、twitter 和 youtube。更多信息请参见启用或禁用社交网络。用于发送团队成员邀请的有效电子邮件地址。当
team: true 时必填。更改社交账户关联页面的副标题。当前显示为 “Click an icon to link a social network”。设为空字符串可移除。请参阅如何修改帮助链接。
使用字符串数组为 user profile 添加标签。这些标签是用于对 user profile 进行有效分类与管理的内部组织工具。
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"title": "ACME Profile"}' \
-X POST https://api.ayrshare.com/api/profiles
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/profiles", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
title: "ACME Profile", // required
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {'title': 'ACME Profile'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.post('https://api.ayrshare.com/api/profiles',
json=payload,
headers=headers)
print(r.json())
<?php
require 'vendor/autoload.php'; // Composer auto-loader using Guzzle. See .../guzzlephp.org/en/stable/overview.html
$client = new GuzzleHttp\Client();
$res = $client->request(
'POST',
'https://api.ayrshare.com/api/profiles',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'title' => ['ACME Profile'],
]
);
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
package main
import (
"bytes"
"encoding/json"
"log"
"net/http"
)
func main() {
message := map[string]interface{}{
"title": "ACME Profile"
}
bytesRepresentation, err := json.Marshal(message)
if err != nil {
log.Fatalln(err)
}
req, _ := http.NewRequest("POST", "https://api.ayrshare.com/api/profiles",
bytes.NewBuffer(bytesRepresentation))
req.Header.Add("Content-Type", "application/json; charset=UTF-8")
req.Header.Add("Authorization", "Bearer API_KEY")
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal("Error:", err)
}
res.Body.Close()
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace CreateProfilePOSTRequest_csharp
{
class CreateProfile
{
static async Task Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://api.ayrshare.com/api/profiles";
string json = "{\"title\": \"ACME Profile\"}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);
try
{
var content = new StringContent(json, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(url, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (HttpRequestException e)
{
Console.WriteLine($"Error: {e.Message}");
}
}
}
}
}
{
"status": "success",
"title": "Digg It",
"refId": "140b8709bd6ade099b242d895e268fb886130c53",
"profileKey": "7TVRLEZ-24A43C0-NJW0Z82-F11984N",
"messagingActive": true // true if messaging for this user profile is active
}
{
"action": "create",
"status": "error",
"code": 146,
"message": "Profile title already exists."
}
⌘I
