ASP.NET MVC的Facebook [英] ASP.NET MVC Facebook

查看:98
本文介绍了ASP.NET MVC的Facebook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一个看似简单的事情,但有麻烦完成它。我想在我的Facebook墙上自动化张贴。基本上我有一个ASP.NET MVC网站,我在发布更新,我要到后自动提交到我的墙上。

I am trying to do a seemingly simple thing, but having trouble accomplishing it. I am trying to automate the posting on my Facebook wall. Basically I have a ASP.NET MVC website that I post updates on, and I want to automatically submit the post to my wall.

我看到了很多关于FB Connect和获取数据的东西,我只是想发布。

I see a lot of stuff on FB Connect and getting data, I just want to post.

感谢任何帮助或指导。

更新:只是想复活,成为一个更加清楚一点在我的描述,我没有得到任何地方。

UPDATE: Just trying to resurrect and be a little more clear in my description as I am not getting anywhere.

我有,我想用一个文本框和一个按钮的页面。当我提交表单我想要的消息发布到的Facebook墙上。我认为这是Facebook的连接,但我得到任何地方对如何自动验证自己和张贴到我的墙上。

I have a page that I want with a text box and a button. When I submit the form I want the message to post to my Facebook wall. I thought it was Facebook Connect, but I am getting no where as to how to automatically authenticate myself and post to my wall.

我想用C#,而不是JavaScript的。

I would like to use C# rather than JavaScript.

private const string ApplicationKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXX";
private const string SecretKey = "XXXXXXXXXXXXXXXXXXXXXXXXXX";
private Facebook.Rest.Api _facebookAPI;
private Facebook.Session.ConnectSession _connectSession;

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(FormCollection form)
{
    _connectSession = new Facebook.Session.ConnectSession(ApplicationKey, SecretKey);
    if (_connectSession.IsConnected())
    {
        _facebookAPI = new Facebook.Rest.Api(_connectSession);
        string response = _facebookAPI.Stream.Publish("This is a generated test");
    }
        return View();
    }
}

该IsConnected()的返回false。
任何帮助是AP preciated。

The IsConnected() is returning false. Any help is appreciated.

推荐答案

这code是正确的,问题是,我没有将我的应用我的个人资料。阿呆想念,但我的想法是,整个事情是不良记录。我有离线访问另一个问题,但这是一个不同的职位。

This code was right, the problem was that I had not added my application to my profile. Dumb miss, but my thought is that the whole thing is poorly documented. I have another issue with offline access, but that is for a different post.

string apiKey = "XXXXXXXXX";
string apiSecret = "XXXXXXXXXXXX";
Facebook.Session.ConnectSession._connectSession = new Facebook.Session.ConnectSession(apiKey, apiSecret);
if (_connectSession.IsConnected)
{
    Facebook.Rest.Api api = new Facebook.Rest.Api(_connectSession);
    string response = api.Stream.Publish("Test", null, null, null, api.Users.Session.UserId);
}

这篇关于ASP.NET MVC的Facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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