如何通过具有Publish_stream权限的API将应用程序添加到页面(我已经创建)?通过具有权限的API将Facebook应用程序添加到页面
这里是我尝试使用应用程序的东西的序列。 使用页面访问令牌代码向页面添加应用程序是将应用程序添加到页面应用程序部分,但无法添加“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_se cret = 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
});
当您发布到'/ {page}/tabs'时,错误信息是什么?这是添加选项卡的正确方法,它看起来像你的代码示例是正确的 – Igy 2012-08-13 21:11:17
好吧,一旦应用程序被添加到一个页面,使用APP访问令牌我想发布消息给页面订阅源,我得到一个异常:(OAuthException - #200)(#200)用户未授权应用程序执行此操作 – user1401299 2012-08-13 21:15:38
您无法使用应用程序访问令牌发布到页面 - 应用程序无法自行发布 - 作为页面,您需要从页面中检索到的页面访问令牌admin – Igy 2012-08-13 21:23:46