开发者

IsAuthorized = False, Facebook C# SDK 4.2.1

开发者 https://www.devze.com 2023-02-05 01:24 出处:网络
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()

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.开发者_StackOverflow社区cs:

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

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


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

    });
0

精彩评论

暂无评论...
验证码 换一张
取 消