开发者

Form data loss when posting from Facebook Canvas iframe application

Here is a brief set of bullet points on what I am trying to accomplish:

  • Use the F开发者_如何转开发acebook C# SDK with asp.net MVC
  • Post custom form data from a Facebook canvas iframe app to server
  • I am currently building off of the MVC sample provided

Them problem I am having is that when I submit the form on the iframe canvas app the only data I get back from Facebook is the signed_request form parameter . What I need is the data from the form.

I have looked at various solutions to the issue (see this link) but I cannot get them to work. When I access the FacebookSession object there is no session key returned so I cannot follow the links guidence.

Any guidence that can be provided on how to do this would be very much appreciated.


ow3n is correct that you need to include signed_request in your post data. Which, for a C# Facebook app (assuming Razor views), means adding this to your form:

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


I ran into the same problem and ended up doing this:

<form method="post" id="form1" target="_top">
<input type="text" id="sometext" />
<input type="submit" id="button" />
</form>

<script language="javascript" type="text/javascript">
$(document).ready(function () {
$("#button").click(function () {
var action = '<%= Url.CanvasAction("Create", "Home") %>';
action += "?sometext=" + escape($("#sometext"));
$("#form1").attr("action", action);
});
}
</script>

The downside to this is now your sending the data along the querystring with a limit for IE of around 2048 characters max before it chops stuff off, the worst thing is that it's exposed and open to users of that machine, especially if it is in a public cafe bar or something and they can see what the last person was posting to your app!

I'd also like to know why the brainyacks at Facebook couldnt just accept the form data posted to them and merely forward it verbatim back to the application --> Idiots!


I was having the same problem passing POST or GET data with a canvas app and found the answer on this post. Just add this input to your form:

<input type="hidden" value="<?php echo $_POST["signed_request"]?>" name="signed_request" />
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜