开发者

getting HTTP 404 error when trying to submit a form in a facebook app

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%...
  1. though I am asking about the php_self in framing.php, I don't see it in the generated url, can someone plea开发者_如何学Gose explain why?
  2. 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 %7D you see in the returned error from Facebook.

$html .= "<form method='POST' action='".$pageToReturnTo."?idArray=".$idArray_imploded."'>

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.

// $pageToReturnTo = $_SERVER['PHP_SELF'];
$pageToReturnTo = 'myscript.php';
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜