khalil
khalil

Reputation: 329

IsAuthorized = False, Facebook C# SDK 4.2.1

I have a problem after upgrading to version 4.2.1. when i try to do an ajax post, im still getting false in authorizer.IsAuthorized()

Default.aspx:

    $('.WallPost').click(function(e){

        //get the form
        var f = $("#<%=Page.Form.ClientID%>");
        //get the action attribute
        var action = 'http://www.domain.com/FacebookTestZone/Call/WallPost.aspx';
        //get the serialized data
        var serializedForm = f.serialize();
        $.post(action, serializedForm, 
            function(txt) { 
                alert(txt);
            }
        );            

    });

WallPost.aspx.cs:

fbApp = new FacebookApp(); 
authorizer = new CanvasAuthorizer(fbApp);

    if (authorizer.IsAuthorized())
    {
        Response.Write("IsAuthorized = True");
    }
    else
    {
        Response.Write("IsAuthorized = False");
    }

Upvotes: 1

Views: 612

Answers (1)

Nate Totten
Nate Totten

Reputation: 8932

You have to send the signed_request value with the ajax request. We no longer support cookies in iframe apps because it was a mess and unreliable. Do something like the following with your form post:

  $('.WallPost').click(function(e){

        //get the form
        var f = $("#<%=Page.Form.ClientID%>");
        //get the action attribute
        var action = 'http://www.domain.com/FacebookTestZone/Call/WallPost.aspx?signed_request=<%=Request.Params["signed_request"] %>';
        //get the serialized data
        var serializedForm = f.serialize();
        $.post(action, serializedForm, 
            function(txt) { 
                alert(txt);
            }
        );            

    });

Upvotes: 2

Related Questions