在C#控制台应用程序中获取Facebook的用户访问令牌

在C#控制台应用程序中获取Facebook的用户访问令牌,c#,facebook-graph-api,console-application,C#,Facebook Graph Api,Console Application,我想创建一个C#控制台应用程序,在我的FaceBook帐户墙上创建帖子 我试图搜索如何获取此内容,但我得到的只是有关web应用程序中的get access\u令牌的信息,我们可以在其中添加重定向URL: 我使用下面的代码在控制台应用程序中获取访问令牌。 但我从下面的代码中得到的输出是: { “访问令牌”:“*******************”, “令牌类型”:“承载者” } 哪个App_ID | App_Secret..where user Access_token应该非常长 这是否可以使用

我想创建一个C#控制台应用程序,在我的FaceBook帐户墙上创建帖子

我试图搜索如何获取此内容,但我得到的只是有关web应用程序中的get access\u令牌的信息,我们可以在其中添加重定向URL:

我使用下面的代码在控制台应用程序中获取访问令牌。 但我从下面的代码中得到的输出是:

{ “访问令牌”:“*******************”, “令牌类型”:“承载者” } 哪个App_ID | App_Secret..where user Access_token应该非常长

这是否可以使用控制台应用程序在facebook帐户墙上发布

    private const string FacebookApiId = "************";
    private const string FacebookApiSecret = "**************************";

    private const string AuthenticationUrlFormat =
         "https://graph.facebook.com/oauth/access_token?client_id={0}&client_secret={1}&grant_type=client_credentials&scope=manage_pages,offline_access,publish_stream";


    static void Main(string[] args)
    {

        string accessToken = GetAccessToken(FacebookApiId, FacebookApiSecret);

        PostMessage(accessToken, "My message");
    }

    static string GetAccessToken(string apiId, string apiSecret)
    {
        string accessToken = string.Empty;
        string url = string.Format(AuthenticationUrlFormat, apiId, apiSecret, "manage_pages,offline_access,publish_stream");

        WebRequest request = WebRequest.Create(url);

        WebResponse response = request.GetResponse();

        using (Stream responseStream = response.GetResponseStream())
        {
            StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);
            String responseString = reader.ReadToEnd();

            NameValueCollection query = HttpUtility.ParseQueryString(responseString);

            accessToken = query["access_token"];
        }

        if (accessToken.Trim().Length == 0)
            throw new Exception("There is no Access Token");

        return accessToken;
    }

你拿到代币了吗?问题是什么?我没有获得用户访问令牌…我只获得了AppID | AppSecret,但作为访问令牌,这不是我需要的。我要一个大长度的加密令牌,你说的对吗?问题是什么?我没有获得用户访问令牌…我只获得了AppID | AppSecret,但作为访问令牌,这不是我需要的。我想要大长度的加密令牌。