如何通过具有Publish_stream权限的API将应用程序添加到页面(我已创建)?
这是我尝试使用应用程序轻松实现的顺序。 使用页面访问令牌代码将应用程序添加到页面是将应用程序添加到页面应用程序部分,但无法添加“publish_stream,manage_pages”权限。
登录Facebook
private const string Scope = "publish_stream,manage_pages";
FacebookClient _fb = new FacebookClient();
var fbLoginUrl = _fb.GetLoginUrl(
new
{
client_id = AppId,
client_secret = Appsecret,
redirect_uri = RedirectUri,
response_type = "code",
scope = Scope,
state = state
});
获取短期访问令牌
if (Request.QueryString["code"] != null)
code = Request.QueryString["code"];
var result = _fb.Post("oauth/access_token",
new
{
client_id = AppId,
client_secret = Appsecret,
redirect_uri = RedirectUri,
code = code,
scope = Scope,
response_type="token"
});
获取长期访问令牌
var result1 = _fb.Post(“oauth / access_token”, 新 { client_id = AppId, client_secret = Appsecret, grant_type =“fb_exchange_token”, fb_exchange_token = Session [“fb_access_token”]为字符串 });
获取页面访问令牌
dynamic accounts = _fb.Get("me/accounts");
使用页面访问令牌将应用程序添加到页面
var sResult = _fb.Post("<PAGE-ID>/tabs",
new
{
app_id = AppId,
access_token = <PAGE ACCESS TOKEN>,
scope = Scope
});
答案 0 :(得分:0)
您的评论似乎是在尝试发布&#39;作为&#39;将应用程序放到页面上 - 这是不可能的。您需要使用从页面管理员检索到的页面访问令牌进行发布,并且此页面访问令牌允许您代表页面发布帖子。应用无法自行发布&#39;。