Adding Facebook Application to a page through API with permissions
How to add an application to a page(which I have created) through API with Publish_stream permissions?
Here is the Sequence of things I have tried sofar using app. Adding App to a page using page access token code is adding app to page apps section but unable to add "publish_stream,manage_pages" permission.
For log in to 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
});
To get short lived access token
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"
});
To get long lived access 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 });
To get Page access Token
dynamic accounts = _fb.Get("me/accounts");
Add App to a Page using Page Access Token
var sResult = _fb.Post("<PAGE-ID>/tabs",
new
{
app_id = AppId,
access_token = <PAGE ACCESS TOKEN>,
scope = Scope
});
It seems from your comments you're trying to post 'as' the app onto a page - this is not possible. You need to post using a page access token retrieved from an admin of the page, and this page access token allows you to make posts on behalf of the page. Apps cannot post 'as themselves'.
链接地址: http://www.djcxy.com/p/61612.html上一篇: 无法扩展Facebook访问令牌