views:

333

answers:

3

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.

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

Thanks for any help or guidance.

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

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.

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

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

A: 

This post might be helpful.

Darin Dimitrov
Thanks for the post, this is what I want to do. But I cannot get automatically authenticated. I will post my code above.
Dustin Laine
I don't see any of the methods you are using in the example given on the Facebook site.
Darin Dimitrov
A: 

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);
}
Dustin Laine
What do you mean with "I had not added my application to my profile"?I think I have the same exact problem!
paskster
I created a Facebook application and then added it to my profile. After that it worked fine. I never got it working as seamless as I wanted, and I still agree with my quote on documentation sucking!
Dustin Laine
Im sorry, but I cant solve my Problem! I now even added my application to my Facebook Profile! If there is no new solution coming up, I have to start another Thread here with the same problem.
paskster
A: 

It could be that you tested your Website on your localhost. The Facebook Cookie is not written out, when you test your Website on localhost. See this link http://forum.developers.facebook.net/viewtopic.php?pid=247332

This might solve your problem: 1) Add "127.0.0.1 localhost.local" to your file 2) Update your FB application Connect settings to use "http://localhost.local/" URL and "localhost.local" domain. 3) Create an IIS Web site on port 80 with the name "localhost.local".
- I had to stop my default web site, which is also on port 80 4) Update my Visual Studio 2010 web application to use IIS with the "http://localhost.local/" url.

To see cookies, make sure to install FireCookies, along with FireBug.

paskster