获取访问令牌到Facebook页面 - WPF [英] Get access token to facebook page - WPF

查看:72
本文介绍了获取访问令牌到Facebook页面 - WPF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个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:


验证应用程序时出错,由于系统错误无法获取应用程序信息。


有人知道我必须做吗?



谢谢!!!

解决方案

不知道你是否能够获得页面永不过期的令牌,所以我将向您解释步骤:


  1. 打开中验证相同的内容。在您的应用程序中使用此


但请注意,如果您的应用是公开的,则不建议在客户端使用此令牌。 >

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:

"Error validating application. Cannot get application info due to a system error."

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:

  1. Open Graph API Explorer

  2. Select your app from the drop-down

  3. Click "Get Access Token" button, and select the manage_pages permission.

  4. 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}
    

  5. Copy the token from step-4 and paste in to the access_token field and call:

    /{page-id}?fields=access_token
    

  6. 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆