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

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

问题描述

我开发一个需要在Facebook的页面的墙后一个WPF应用程序,而这个没有登录窗口。
哦,我想获得访问令牌我的Facebook页面,这是我的代码。

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;
            }
        }



但是我收到一个错误#104。这是一个简单的错误,我需要一个访问令牌做此操作。
然后,我用其他的代码来获取用户访问令牌

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>
        });



但我得到的错误#101:

But I get error #101:

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

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

有人知道是什么我有什么关系?

Someone knows what I have to do?

谢谢!

推荐答案

我不敢肯定,如果你已经能够得到的页面永不过期的令牌,所以我将解释你的步骤:

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. 打开图形API资源管理器

选择从下拉

点击获取访问令牌按钮,并选择 manage_pages 允许

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}


  • 从步骤4中复制令牌并粘贴到的access_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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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