Search code examples
phpfacebookfacebook-graph-apifacebook-iframe

Facebook iframe - how to send form (POST method)?


I have very simple form (the file is called message.php):

<?php
  print_r($_POST);
?>
<form method="post" target="_top" action="<?php echo CANVAS_URL;?>message.php">
  <input type="text" name="your_name" />
  <input type="hidden" name="signed_request" value="<?php echo $_REQUEST['signed_request'];?>" />
  <input type="submit" name="send" />
</form>

I found one solution of this issue - put into the form hidden input with the signed_request - I did it but unfortunately I am still facing with this problem -- I cannot retrieve sent POST data.

If I change the method to method="get", everything is working well, but I would need to data from POST.

Could anyone help me, how to solve this problem? Thanks!


Solution

  • Try this. I don't believe you need to use target in FB canvas aps anymore. Also a form ID would be good.

    <form method="POST" id="my_form" action="message.php">
        <input type="text" name="your_name" />
        <input type="hidden" value="<?php print $_POST["signed_request"] ?>" name="signed_request" />
        <input type="submit" name="submit" />
    </form>