IsAuthorized = False,Facebook C#SDK 4.2.1

时间:2011-01-18 07:18:42

标签: facebook-c#-sdk

升级到4.2.1版后出现问题。当我尝试做一个ajax帖子时,我仍然在授权者中变得虚假.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");
    }

1 个答案:

答案 0 :(得分:2)

您必须使用ajax请求发送signed_request值。我们不再支持iframe应用程序中的cookie,因为它很乱并且不可靠。使用表单发布以下内容:

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

    });