在Facebook页面的墙后无需登录(C#) [英] Post on Facebook Page's wall without having to login (C#)

查看:117
本文介绍了在Facebook页面的墙后无需登录(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面的code(已公布的地方#1)张贴在Facebook页面的墙。

它工作正常,但打开Facebook的登录窗口,如果我没有登录。
是否有可能执行code代表特定的Facebook页面?

管理员帐户

 保护无效的Page_Load(对象发件人,EventArgs的发送)
    {
        字符串APP_ID =123410186463705;
        字符串app_secret =1234ecd9bea862197372de656eb3d7b;        //使用Facebook的SDK的.NET
        变种FB =新FacebookClient();
        动态结果= fb.Get(OAuth的/的access_token,新
        {
          CLIENT_ID = APP_ID,
          client_secret = app_secret,
          grant_type =client_credentials
          范围=manage_pages,offline_access,publish_stream
          REDIRECT_URI = Request.Url.AbsoluteUri
        });        VAR app_token = result.access_token;        VAR的客户=新FacebookClient(app_token);        动态参数=新ExpandoObject();
        parameters.message =看看这个有趣的文章;
        parameters.link =htt​​p://www.natiska.com/article.html;
        parameters.picture =htt​​p://www.natiska.com/dav.png;
        parameters.name =文章标题
        parameters.caption =标题为链接;        // 446533181408238是我的粉丝专页
        client.Post(/ 446533181408238 /饲料,参数);
    }


解决方案

是的,这是可能的。你需要使用一个页面访问令牌。

生成页面访问令牌。

一旦你收到一个页面访问令牌,可以存储,因为它永远不会过期(如果通过长寿命的用户令牌/服务器端用户令牌生成)。最后初始化 FacebookClient 与令牌。

一个C#教程具体是<一个href=\"http://www.jamescrowley.co.uk/2011/02/03/posting-to-facebook-page-using-c-sdk-from-offline-app/\"相对=nofollow>此处。文章真的老了,并使用pcated去$ P $ offline_access 许可,但ATLEAST你会得到逻辑权利。

I'm using the following code (which has been posted somewhere on Stackoverflow) to post on Facebook Page's wall.

It works fine, but it opens Facebook Login window if I'm not logged in. Is it possible to execute the code on behalf of administrator account of particular Facebook Page?

    protected void Page_Load(object sender, EventArgs e)
    {
        string app_id = "123410186463705";
        string app_secret = "1234ecd9bea862197372de656eb3d7b";

        // using Facebook SDK for .NET
        var fb = new FacebookClient();
        dynamic result = fb.Get( "oauth/access_token", new
        {
          client_id = app_id,
          client_secret = app_secret,
          grant_type = "client_credentials",
          scope = "manage_pages,offline_access,publish_stream",
          redirect_uri = Request.Url.AbsoluteUri
        } );

        var app_token = result.access_token;

        var client = new FacebookClient(app_token);

        dynamic parameters = new ExpandoObject();
        parameters.message = "Check out this funny article";
        parameters.link = "http://www.natiska.com/article.html";
        parameters.picture = "http://www.natiska.com/dav.png";
        parameters.name = "Article Title";
        parameters.caption = "Caption for the link";

        //446533181408238 is my fan page
        client.Post("/446533181408238/feed", parameters);
    }

解决方案

Yes, it's possible. You need to use a page access token.

Generating a Page Access Token.

Once you receive a page access token, you can store it as it never expires(if generated through long-lived user token/server side user token). Finally initialize your FacebookClient with that token.

A C# specific tutorial is here. The article really old and using the deprecated offline_access permission, but atleast you will get the logic right.

这篇关于在Facebook页面的墙后无需登录(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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