Question

I'm currently trying to simply post on my own wall with a windows phone app written in c#/xaml.

This is my current status:

  • I can login and authenticate -> I get an access token.
  • Now I can post to my wall via button click.
  • I save the Current AuthToken.
  • I close the app.
  • I reopen the app and try to click the button again (using the same AuthToken, which is still valid according to https://developers.facebook.com/tools/debug/accesstoken -> I'm getting WebException and OAuthException.

Where is my problem? How to I correctly store the accessToken to use it the next time the app opens? [Or how do I manage the users session in a better way?]

few pieces of code I use:

private void Test_Click(object sender, RoutedEventArgs e)
{
        string acccessToken = App.AccessToken;
        FacebookClient appp = new FacebookClient(acccessToken);
        System.Diagnostics.Debug.WriteLine(acccessToken);
        try
        {
            appp.PostTaskAsync("me/feed", new { message = "hi" });
        }
        catch (FacebookOAuthException)
        {

        }
}

-

private async Task Authenticate()
    {
        string message = String.Empty;
        try
        {
            session = await App.FacebookSessionClient.LoginAsync("user_about_me,read_stream,publish_actions");
            App.AccessToken = session.AccessToken;
            App.FacebookId = session.FacebookId;
            App.isAuthenticated = true;
        }
        catch (InvalidOperationException e)
        {
        }

    }
Was it helpful?

Solution

Okay, silly thing I was not aware of...

Facebook seems to not accepting the same Post twice in a short period of time (spam protection I guess). After I tried it again after five minutes or so, it was working like expected!

The only thing I quite don't get is why an OAuthException is being thrown...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top