如何通過具有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