问题描述
我正在开发一个WPF应用程序,需要在Facebook的页面的墙壁上发布,而不需要登录窗口。嗯,我想要访问我的Facebook页面的访问令牌,这是我的代码。
var fb =新的FacebookClient();
string token =;
动态帐户= fb.Get(/< USER_ID>/ accounts);
foreach(帐户中的动态帐户)
{
if(account.id ==< PAGE_ID>)
{
token = account.access_token;
break;
}
}
但是我收到错误#104。这是一个简单的错误,我需要访问令牌来执行此操作。
然后我使用其他代码来获取用户访问令牌
var fb = new FacebookClient();
dynamic result = fb.Get(oauth / access_token,new
{
client_id =< PAGE_ID>,
client_secret =< APP_SECRET>,
grant_type =fb_exchange_token,
fb_exchange_token =< USER_TOKEN>
});
但是我收到错误#101:
有人知道我必须做吗?
谢谢!!!
不知道你是否能够获得页面永不过期的令牌,所以我将向您解释步骤:
-
打开中验证相同的内容。在您的应用程序中使用此
但请注意,如果您的应用是公开的,则不建议在客户端使用此令牌。 >
I am developing a WPF application that needs post on wall of a facebook's Page, and this without login window.Well, I want to get access token for my facebook page, and this is my code.
var fb = new FacebookClient();
string token = "";
dynamic accounts = fb.Get("/"<USER_ID>"/accounts");
foreach (dynamic account in accounts)
{
if (account.id == <PAGE_ID>)
{
token = account.access_token;
break;
}
}
But I receive a error #104. It is a simple error, that I need a access token to do this operation.Then I use other code to get the user access token
var fb = new FacebookClient();
dynamic result = fb.Get("oauth/access_token", new
{
client_id = <PAGE_ID>,
client_secret = <APP_SECRET>,
grant_type = "fb_exchange_token",
fb_exchange_token = <USER_TOKEN>
});
But I get error #101:
Someone knows what I have to do?
Thanks!!!
I'm not sure if you've been able to get a never expiring token for the page, so I'll explain you the steps:
Open Graph API Explorer
Select your app from the drop-down
Click "Get Access Token" button, and select the
manage_pages
permission.Copy the token and run this in the browser:
https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id={app-id}&client_secret={app-secret}&fb_exchange_token={step-3-token}
Copy the token from step-4 and paste in to the access_token field and call:
/{page-id}?fields=access_token
The token you get now is a never-expiring token, you can validate the same in Debugger .Use this in your app.
But beware, its not recommended to use this token on client side if your app is public.
这篇关于获取访问令牌到Facebook页面 - WPF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!