Search code examples
phpformsfacebook-php-sdkfeed

Text user wrote in form doesn't appear when variables passed to a feed dialog php file


I am having an odd issue. I am trying to pass the information people filled out in a form to the facebook feed dialog by $_POSTing the name of each field into the field dialog. Facebook has an example of how to use the feed dialog.

<?php
$app_id = "YOUR_APP_ID";
$canvas_page = "YOUR_CANVAS_PAGE_URL";
$message = "Apps on Facebook.com are cool!";
$feed_url = "https://www.facebook.com/dialog/feed?app_id="
. $app_id . "&redirect_uri=" . urlencode($canvas_page)
. "&message=" . $message;

if (empty($_REQUEST["post_id"])) {
    echo("<script> top.location.href='" . $feed_url . "'</script>");
} else {
    echo ("Feed Post Id: " . $_REQUEST["post_id"]);
}
?>

I thought you should be able to put all the names you put in the name field by putting $message = $_POST['aName'] . $_POST['anotherName']; to the $message variable. I tried that approach, but it didn't work. I tried using $_POST and $_REQUEST, but neither populates the feed dialog with the info. I just get a blank feed dialog, when it should be filled with the info from the form. Any ideas on why this is happening??

Note: I am using your normal<form action="sendformnames.php" method="post" target="_blank"> to send the info across.

2nd Note: Someone else had this problem and it was solved by using a hidden text field that has the value of signed_request. I tried doing this, but it didn't fix the issue.

Edit: Thank you for posting that link. Would using the publish_stream parameter work for this? Or did facebook completely remove this feature?


Solution

  • Breaking Change: "message" parameter ignored in Feed Dialog