I am building a Facebook survey, in which there are multiple questions per a random selected friend.
my methodology for doing so is to show a php page with one friend and his/her questions
and when the user submits, it should post to the same php page but with an array containing the left to be shown friends ids.
this is I have such architecture and relevant code:
home.php – logging into facebook
framing.php – managing the survey
$idArray = friends id array...
$pageToReturnTo = $_SERVER['PHP_SELF'];
$q_html = questionnaire($idArray,$pageToReturnTo);
q.php – containing a functions that gets the current survey from db and manipulate it to html
function questionnaire($idArray,$pageToReturnTo){
...
$idArray_imploded = implode(",",$idArray)
$html .= "<form method='POST' action='".$pageToReturnTo."}?idArray=".$idArray_imploded."'>
....
return $html;
}
the problem is that the facebook returns an error like this:
Received HTTP error code 404 while loading http://www.mydomain.com/%7D?idArray=757010120%...
- though I am asking about the php_self in framing.php, I don’t see it in the generated url, can someone please explain why?
- how can I resolve this? if not can you please suggest an alternative?
thanks a million!
Looks like you have an extra
}in your $html right before?idArray=. That’s the%7Dyou see in the returned error from Facebook.Also, you should check to ensure that
$_SERVER['PHP_SELF']actually contains a value. It looks like it may be empty on your server. There are a few other ways to get the name of the currently running script. For testing you could just replace$_SERVER['PHP_SELF']with the hardcoded name of the php script, just to make sure that your script is actually working.