如何通过具有 Publish_stream 权限的 API 将应用程序添加到页面(我已创建)?
这是迄今为止我使用 app.js 尝试过的一系列事情。使用页面访问令牌代码将应用程序添加到页面正在将应用程序添加到页面应用程序部分,但无法添加“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", new { client_id = AppId, client_secret = Appsecret, grant_type = "fb_exchange_token", fb_exchange_token= Session["fb_access_token"] as string });
获取页面访问令牌
dynamic accounts = _fb.Get("me/accounts");
使用页面访问令牌将应用程序添加到页面
var sResult = _fb.Post("<PAGE-ID>/tabs",
new
{
app_id = AppId,
access_token = <PAGE ACCESS TOKEN>,
scope = Scope
});