如何使用Facebook Graph API为帖子添加“号召性用语”?是可能还是免费? 提前谢谢。
答案 0 :(得分:3)
您可以添加"号召性用语"页面上的帖子按钮(例如粉丝页面,商业页面等),但不包括个人时间表。
添加"号召性用语"使用Graph API按钮到页面帖子,只需包含call_to_action
参数:
call_to_action={"type":"SHOP_NOW","value":{"link":"http://www.amazon.com"}}
可用的列表"号召性用语"值列在此不相关的页面上: https://developers.facebook.com/docs/marketing-api/mobile-app-ads/v2.5#cta_definitions
同样,请记住call_to_action
param仅适用于Page帖子。如果您将该参数包含在个人时间轴的帖子中,则会被忽略。
使用"号召性用语发布到Facebook页面的整个C#代码"按钮:
string facebookPageID = ""; // a page id needed here. NOT a user id.
string facebookPageAccessToken = ""; // a page access token needed here
string shareLink = "http://www.stackoverflow.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();
}
答案 1 :(得分:0)
这在官方文档中得到了很好的解释:https://www.facebook.com/help/312169205649942
......或在本文中:https://www.facebook.com/business/news/call-to-action-button
Afaik现在无法使用Graph API执行此操作。
编辑:我的不好,我认为这将是关于页面标题中的号召性用语按钮。绝对可以以编程方式向页面帖子添加号召性用语按钮,您只需要包含指向页面帖子的链接即可。我在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