Facebook Post 使用图形的号召性用语按钮 API
Facebook Post Call to Action button using Graph API
如何使用 Facebook Graph API 为 post 添加 "Call To Action"?有可能还是免费的?
提前致谢。
这在官方文档中解释得很好:https://www.facebook.com/help/312169205649942
...或本文中:https://www.facebook.com/business/news/call-to-action-button
Afaik 目前无法使用图表 API 执行此操作。
编辑:不好意思,我认为这与页面 header 中的号召性用语按钮有关。绝对可以通过编程方式将号召性用语按钮添加到页面 post,您只需要在页面 post 中包含一个 link。我在 API 资源管理器中尝试过,只需替换页面 ID 并确保您使用的页面令牌具有 publish_pages
权限:
https://developers.facebook.com/tools/explorer/?method=POST&path=[PAGE-ID]%2Ffeed&version=v2.5&message=test&link=http%3A%2F%2Fwww.devils-heaven.com&call_to_action={%22type%22%3A%22SHOP_NOW%22%2C%22value%22%3A{%22link%22%3A%22http%3A%2F%2Fwww.devils-heaven.com%22}}
此处指定:https://developers.facebook.com/docs/marketing-api/mobile-app-ads/v2.5#cta_definitions
您可以将 post 上的 "Call to Action" 按钮添加到页面(例如粉丝页面、企业页面等),但不能添加到个人时间轴。
要使用图形 API 将 "Call to Action" 按钮添加到页面 post,只需包含 call_to_action
参数:
call_to_action={"type":"SHOP_NOW","value":{"link":"http://www.amazon.com"}}
此无关页面列出了可用 "Call to Action" 值的列表:
https://developers.facebook.com/docs/marketing-api/mobile-app-ads/v2.5#cta_definitions
同样,请记住 call_to_action
参数仅适用于第 post 页。如果您将该参数包含在个人时间轴的 post 中,它将被忽略。
整个 C# 代码 post 到带有 "Call to Action" 按钮的 Facebook 页面:
string facebookPageID = ""; // a page id needed here. NOT a user id.
string facebookPageAccessToken = ""; // a page access token needed here
string shareLink = "http://www.whosebug.com";
string url = "https://graph.facebook.com/v2.4/"
+ facebookPageID + "/feed?access_token=" + facebookPageAccessToken
+ "&link=" + HttpUtility.UrlEncode(shareLink)
+ "&message=" + HttpUtility.UrlEncode("Check this out")
+ "&call_to_action=" + HttpUtility.UrlEncode("{\"type\":\"SHOP_NOW\",\"value\":{\"link\":\"" + shareLink + "\"}}");
string resp = "";
try
{
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(url);
httpRequest.Method = "POST";
using (HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse())
{
using (Stream responsestream = httpResponse.GetResponseStream())
{
if (responsestream != null)
{
using (StreamReader bodyreader = new StreamReader(responsestream))
{
resp = bodyreader.ReadToEnd();
}
}
}
}
}
catch (Exception ex)
{
resp = ex.ToString();
}
上面的代码将创建这个示例 post:
如何使用 Facebook Graph API 为 post 添加 "Call To Action"?有可能还是免费的? 提前致谢。
这在官方文档中解释得很好:https://www.facebook.com/help/312169205649942
...或本文中:https://www.facebook.com/business/news/call-to-action-button
Afaik 目前无法使用图表 API 执行此操作。
编辑:不好意思,我认为这与页面 header 中的号召性用语按钮有关。绝对可以通过编程方式将号召性用语按钮添加到页面 post,您只需要在页面 post 中包含一个 link。我在 API 资源管理器中尝试过,只需替换页面 ID 并确保您使用的页面令牌具有 publish_pages
权限:
https://developers.facebook.com/tools/explorer/?method=POST&path=[PAGE-ID]%2Ffeed&version=v2.5&message=test&link=http%3A%2F%2Fwww.devils-heaven.com&call_to_action={%22type%22%3A%22SHOP_NOW%22%2C%22value%22%3A{%22link%22%3A%22http%3A%2F%2Fwww.devils-heaven.com%22}}
此处指定:https://developers.facebook.com/docs/marketing-api/mobile-app-ads/v2.5#cta_definitions
您可以将 post 上的 "Call to Action" 按钮添加到页面(例如粉丝页面、企业页面等),但不能添加到个人时间轴。
要使用图形 API 将 "Call to Action" 按钮添加到页面 post,只需包含 call_to_action
参数:
call_to_action={"type":"SHOP_NOW","value":{"link":"http://www.amazon.com"}}
此无关页面列出了可用 "Call to Action" 值的列表: https://developers.facebook.com/docs/marketing-api/mobile-app-ads/v2.5#cta_definitions
同样,请记住 call_to_action
参数仅适用于第 post 页。如果您将该参数包含在个人时间轴的 post 中,它将被忽略。
整个 C# 代码 post 到带有 "Call to Action" 按钮的 Facebook 页面:
string facebookPageID = ""; // a page id needed here. NOT a user id.
string facebookPageAccessToken = ""; // a page access token needed here
string shareLink = "http://www.whosebug.com";
string url = "https://graph.facebook.com/v2.4/"
+ facebookPageID + "/feed?access_token=" + facebookPageAccessToken
+ "&link=" + HttpUtility.UrlEncode(shareLink)
+ "&message=" + HttpUtility.UrlEncode("Check this out")
+ "&call_to_action=" + HttpUtility.UrlEncode("{\"type\":\"SHOP_NOW\",\"value\":{\"link\":\"" + shareLink + "\"}}");
string resp = "";
try
{
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(url);
httpRequest.Method = "POST";
using (HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse())
{
using (Stream responsestream = httpResponse.GetResponseStream())
{
if (responsestream != null)
{
using (StreamReader bodyreader = new StreamReader(responsestream))
{
resp = bodyreader.ReadToEnd();
}
}
}
}
}
catch (Exception ex)
{
resp = ex.ToString();
}
上面的代码将创建这个示例 post: