当CanvasAuthorizer.Permissions具有多个权限时,页面被捕获

时间:2011-06-14 14:23:17

标签: facebook-c#-sdk

我有一个网络项目(不是mvc),我正在尝试了解facebook集成(我是facebook dev noob)。在我的页面中,我有一些简单的html和一个asp.net按钮。我为signed_request添加了一个隐藏字段(对于按钮回发),这似乎也没问题。当我尝试在page_load中添加多个权限时,会出现此问题。如果我只检查user_about_me权限,页面似乎正常工作。如果我添加了publish_stream权限,那么页面会不断循环,只是一遍又一遍地加载(每次重定向)。这是我的page_load代码,当它循环时,使它不循环我只删除逗号和第二个权限。奇怪的是,EITHER权限本身就有效:

 protected void Page_Load(object sender, EventArgs e)
{
  var auth = new CanvasAuthorizer();

  auth.Permissions = new[] { "user_about_me,publish_stream" };
  if (auth.Authorize())
  {
    var fb = new FacebookWebClient();
    dynamic me = fb.Get("me");

    lblAuth.Text = string.Format("User {0} has given permission for this app.", me.name);

  }
  else
  {
    lblAuth.Text = "You have not given permission to this application";
  }
}

我的aspx看起来像这样:

<asp:Label ID="lblAuth" runat="server" Text=""></asp:Label>
<% if(!string.IsNullOrEmpty(Request.Params["signed_request"])) { %>

<input type="hidden" name="signed_request" value="<%= Request.Params["signed_request"] %>" />

<% } %>
<asp:Button ID="btnPlaceOrder" runat="server" Text="Place Order" 
        onclick="btnPlaceOrder_Click" />&nbsp;
        <asp:Label ID="lblOrderPlaced" runat="server" Text=""></asp:Label>

感谢您的帮助!! -Jeff

1 个答案:

答案 0 :(得分:1)

更改

auth.Permissions = new[] { "user_about_me,publish_stream" };

 auth.Permissions = new[] { "user_about_me", "publish_stream" };