curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-H "X-Twitter-OAuth1-Api-Key: YOUR_CONSUMER_KEY" \
-H "X-Twitter-OAuth1-Api-Secret: YOUR_CONSUMER_SECRET" \
-d '{"profileKey": "PROFILE_KEY"}' \
-X POST https://api.ayrshare.com/api/profiles/generateJWT
const API_KEY = "API_KEY";
const PROFILE_KEY = "PROFILE_KEY";
fetch("https://api.ayrshare.com/api/profiles/generateJWT", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`,
"X-Twitter-OAuth1-Api-Key": "YOUR_CONSUMER_KEY",
"X-Twitter-OAuth1-Api-Secret": "YOUR_CONSUMER_SECRET"
},
body: JSON.stringify({
profileKey: PROFILE_KEY, // required
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {'profileKey': 'PROFILE_KEY'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY',
'X-Twitter-OAuth1-Api-Key': 'YOUR_CONSUMER_KEY',
'X-Twitter-OAuth1-Api-Secret': 'YOUR_CONSUMER_SECRET'}
r = requests.post('https://api.ayrshare.com/api/profiles/generateJWT',
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/post',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'json' => [
'profileKey' => 'PROFILE_KEY', // required
]
]
);
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace GenerateJWTRequest_csharp
{
class GenerateJWT
{
static async Task Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://api.ayrshare.com/api/profiles/generateJWT";
try
{
var sendData = new
{
profileKey = "PROFILE_KEY"
};
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);
string jsonData = JsonConvert.SerializeObject(sendData);
var content = new StringContent(jsonData, 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($"HTTP request error: {e.Message}");
}
catch (Exception e)
{
Console.WriteLine($"Unexpected error: {e.Message}");
}
}
}
}
{
"status": "success",
"title": "User Profile Title",
"token": "ayr_ls_kJ8mQ2vX9pLnR4tYwZ6aBcD1eFgH3iJkLmN0oPqRsTu",
"url": "https://profile.ayrshare.com?session=ayr_ls_kJ8mQ2vX9pLnR4tYwZ6aBcD1eFgH3iJkLmN0oPqRsTu&domain=PROVIDED_DOMAIN",
"emailSent": true,
"expiresIn": "5m"
}
{
"action": "JWT",
"status": "error",
"code": 189,
"message": "Error generating JWT. Check the sent parameters.",
"details": "Missing or incorrect domain."
}
{
"action": "JWT",
"status": "error",
"code": 188,
"message": "Both twitterApiKey and twitterApiSecret are required. You provided only one."
}
{
"action": "JWT",
"status": "error",
"code": 434,
"message": "X/Twitter API credentials were provided in both the request headers and the request body. Please use the headers only. See https://www.ayrshare.com/docs/apis/profiles/generate-jwt"
}
Profiles
リンク用 URL の生成 (generateJWT)
generateJWT エンドポイントで User Profile のソーシャル連携用 URL を作成します。
POST
/
profiles
/
generateJWT
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-H "X-Twitter-OAuth1-Api-Key: YOUR_CONSUMER_KEY" \
-H "X-Twitter-OAuth1-Api-Secret: YOUR_CONSUMER_SECRET" \
-d '{"profileKey": "PROFILE_KEY"}' \
-X POST https://api.ayrshare.com/api/profiles/generateJWT
const API_KEY = "API_KEY";
const PROFILE_KEY = "PROFILE_KEY";
fetch("https://api.ayrshare.com/api/profiles/generateJWT", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`,
"X-Twitter-OAuth1-Api-Key": "YOUR_CONSUMER_KEY",
"X-Twitter-OAuth1-Api-Secret": "YOUR_CONSUMER_SECRET"
},
body: JSON.stringify({
profileKey: PROFILE_KEY, // required
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {'profileKey': 'PROFILE_KEY'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY',
'X-Twitter-OAuth1-Api-Key': 'YOUR_CONSUMER_KEY',
'X-Twitter-OAuth1-Api-Secret': 'YOUR_CONSUMER_SECRET'}
r = requests.post('https://api.ayrshare.com/api/profiles/generateJWT',
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/post',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'json' => [
'profileKey' => 'PROFILE_KEY', // required
]
]
);
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace GenerateJWTRequest_csharp
{
class GenerateJWT
{
static async Task Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://api.ayrshare.com/api/profiles/generateJWT";
try
{
var sendData = new
{
profileKey = "PROFILE_KEY"
};
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);
string jsonData = JsonConvert.SerializeObject(sendData);
var content = new StringContent(jsonData, 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($"HTTP request error: {e.Message}");
}
catch (Exception e)
{
Console.WriteLine($"Unexpected error: {e.Message}");
}
}
}
}
{
"status": "success",
"title": "User Profile Title",
"token": "ayr_ls_kJ8mQ2vX9pLnR4tYwZ6aBcD1eFgH3iJkLmN0oPqRsTu",
"url": "https://profile.ayrshare.com?session=ayr_ls_kJ8mQ2vX9pLnR4tYwZ6aBcD1eFgH3iJkLmN0oPqRsTu&domain=PROVIDED_DOMAIN",
"emailSent": true,
"expiresIn": "5m"
}
{
"action": "JWT",
"status": "error",
"code": 189,
"message": "Error generating JWT. Check the sent parameters.",
"details": "Missing or incorrect domain."
}
{
"action": "JWT",
"status": "error",
"code": 188,
"message": "Both twitterApiKey and twitterApiSecret are required. You provided only one."
}
{
"action": "JWT",
"status": "error",
"code": 434,
"message": "X/Twitter API credentials were provided in both the request headers and the request body. Please use the headers only. See https://www.ayrshare.com/docs/apis/profiles/generate-jwt"
}
User Profile のソーシャル連携用 URL を作成します。エンドポイント名は引き続き
generateJWT ですが、返されるトークンは不透明な文字列であり JWT ではありません。
詳細については、リンク用 URL の概要をご覧ください。
リンク用 URLの有効期限は5分間です。5分後には、新しいリンク用 URLを生成する必要があります。
追加オプションについては、Max Packの
expiresInをご覧ください。返される
token は ayr_ls_ で始まる不透明な文字列です。デコード可能な JWT ではなく、
読み取れるペイロードは含まれません。url は返されたままユーザーに渡し、token は中身を調べる
ものではなく保管する資格情報として扱ってください。すでに作成済みのリンクは引き続き利用できます。POST /profiles/link-sessions は同じ処理をレガシーパラメータなしで行い、さらにリンクの状態確認や
失効も可能です。Link Session の作成を参照してください。ヘッダーパラメータ
string
X Developer PortalからのX API Key(Consumer Key)。
twitterApiKeyボディパラメータの代替となります。指定すると、生成されるリンク用 URLはOAuth連携にあなたのXデベロッパーアプリを使用します。string
X Developer PortalからのX API Secret(Consumer Secret)。
twitterApiSecretボディパラメータの代替となります。X-Twitter-OAuth1-Api-Keyが指定されている場合は必須です。推奨: 他のすべてのAyrshare APIエンドポイントとの一貫性のため、X認証情報をヘッダー(
X-Twitter-OAuth1-Api-KeyおよびX-Twitter-OAuth1-Api-Secret)経由で渡してください。twitterApiKeyおよびtwitterApiSecretボディパラメータは、後方互換性のため引き続きサポートされます。ボディパラメータ
string
アプリのドメイン。オンボーディング中に付与された正確なドメインを使用してください。任意。省略した場合はアカウント自身のドメインが使用されます。送信する場合は、アカウントに登録済みのドメインである必要があります。
string
非推奨
現在は使用されていません。フィールドは受け付けられますが無視されるため、既存の連携は変更なしで動作し続けます。リンク用 URL は署名されなくなったため、送信する鍵はありません。このフィールドは削除でき、この用途のために秘密鍵を保管する必要もなくなります。
string
必須
User Profile Key。このフィールドではAPI Keyを使用できません。
boolean
デフォルト:false
現在のセッションを自動的にログアウトします。パフォーマンスに影響するため、本番環境での使用は推奨しません。詳細については、プロフィールセッションの自動ログアウトをご覧ください。
string
「Done」ボタンまたはロゴ画像がクリックされたときにリダイレクトするURLを指定します。URLは返されるリンク用 URL内で自動的に短縮されます。リダイレクトURLにクエリパラメータ
origin=trueを追加することで、オリジンオープナーウィンドウのリダイレクトができます。array
連携ページに表示するソーシャルネットワークを指定します。これにより、Social Networksページで構成されたソーシャルネットワークが上書きされます。
Only display Facebook, X/Twitter, LinkedIn, and TikTok
{
"allowedSocial": ["facebook", "twitter", "linkedin", "tiktok"]
}
string
このURLのソーシャル連携ページでユーザーがInstagramボタンをクリックしたときに使用するInstagram連携フローを上書きします。有効な値:省略した場合、連携ページはアカウント全体のInstagram Login設定を使用します。詳細については、Instagram連携方法をご覧ください。
instagram: Direct Instagram Login、Facebookページ不要。facebook: 連携済みのFacebookページを経由してInstagramを連携。
Force direct Instagram Login for this linking session
{
"instagramLinkMethod": "instagram"
}
boolean
非推奨
現在は使用されていません。フィールドは受け付けられますが無視されます。検証すべき署名付きトークンはありません。返される
token は、ユーザーが URL を開いたときにリンクページ側で検証されます。boolean
非推奨
現在は使用されていません。
privateKey が読み取られなくなったため、フィールドは受け付けられますが無視されます。object
デフォルト:5
ソーシャル連携ページに直接アクセスするためのリンクを含むConnect Accountsメールを送信します。詳細については、Connect Accountsメールをご覧ください。
X API認証情報を含めると、生成されるリンク用 URLは自身のXデベロッパーアプリを使用してOAuth連携を開始します。エンドユーザーはX承認画面であなたのアプリ名を目にすることになります。
必須: この機能を使用する前に、Xデベロッパーアプリ設定(Authentication settings > Callback URI / Redirect URL)に以下のコールバックURLを追加する必要があります:
https://profile.ayrshare.com/social-accountshttps://app.ayrshare.com/social-accounts
403 Callback URL not approvedエラーで失敗します。curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-H "X-Twitter-OAuth1-Api-Key: YOUR_CONSUMER_KEY" \
-H "X-Twitter-OAuth1-Api-Secret: YOUR_CONSUMER_SECRET" \
-d '{"profileKey": "PROFILE_KEY"}' \
-X POST https://api.ayrshare.com/api/profiles/generateJWT
const API_KEY = "API_KEY";
const PROFILE_KEY = "PROFILE_KEY";
fetch("https://api.ayrshare.com/api/profiles/generateJWT", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`,
"X-Twitter-OAuth1-Api-Key": "YOUR_CONSUMER_KEY",
"X-Twitter-OAuth1-Api-Secret": "YOUR_CONSUMER_SECRET"
},
body: JSON.stringify({
profileKey: PROFILE_KEY, // required
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {'profileKey': 'PROFILE_KEY'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY',
'X-Twitter-OAuth1-Api-Key': 'YOUR_CONSUMER_KEY',
'X-Twitter-OAuth1-Api-Secret': 'YOUR_CONSUMER_SECRET'}
r = requests.post('https://api.ayrshare.com/api/profiles/generateJWT',
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/post',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'json' => [
'profileKey' => 'PROFILE_KEY', // required
]
]
);
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace GenerateJWTRequest_csharp
{
class GenerateJWT
{
static async Task Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://api.ayrshare.com/api/profiles/generateJWT";
try
{
var sendData = new
{
profileKey = "PROFILE_KEY"
};
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);
string jsonData = JsonConvert.SerializeObject(sendData);
var content = new StringContent(jsonData, 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($"HTTP request error: {e.Message}");
}
catch (Exception e)
{
Console.WriteLine($"Unexpected error: {e.Message}");
}
}
}
}
{
"status": "success",
"title": "User Profile Title",
"token": "ayr_ls_kJ8mQ2vX9pLnR4tYwZ6aBcD1eFgH3iJkLmN0oPqRsTu",
"url": "https://profile.ayrshare.com?session=ayr_ls_kJ8mQ2vX9pLnR4tYwZ6aBcD1eFgH3iJkLmN0oPqRsTu&domain=PROVIDED_DOMAIN",
"emailSent": true,
"expiresIn": "5m"
}
{
"action": "JWT",
"status": "error",
"code": 189,
"message": "Error generating JWT. Check the sent parameters.",
"details": "Missing or incorrect domain."
}
{
"action": "JWT",
"status": "error",
"code": 188,
"message": "Both twitterApiKey and twitterApiSecret are required. You provided only one."
}
{
"action": "JWT",
"status": "error",
"code": 434,
"message": "X/Twitter API credentials were provided in both the request headers and the request body. Please use the headers only. See https://www.ayrshare.com/docs/apis/profiles/generate-jwt"
}