i'm using this code to invite friends to my facebook application
<?php
$app_id = "12165444444444444";
$canvas_page = "http://www.domain.net/facebook/app/";
$message = "Would you like to join me in this great app?";
$requests_url = "https://www.facebook.com/dialog/apprequests?app_id="
. $app_id . "&redirect_uri=" . urlencode($canvas_page)
. "&message=" . $message;
if (empty($_REQUEST["request_ids"])) {
echo("<script> top.location.href='" . $requests_url . "'</script>");
} else {
echo "Request Ids: ";
print_r($_REQUEST开发者_JS百科["request_ids"]);
}
?>
but after sending the invitations the page keeps refreshing in like infinit loop
what is wrong with that?
Since the request_ids
parameter will only be added to the URL if the user has just accepted an application request, the following will happen:
- A user visits the page, and then is redirected to a request dialog (
$requests_url
). - The user either invites friends or cancels the dialog. They are redirected back to your application's canvas page (
$canvas_page
). - Since
$canvas_page
does not contain therequest_ids
parameter, the user is redirected to a request dialog (see #1).
Without testing, I suspect that since a requests dialog was just created (and closed), Facebook is automatically redirecting to the redirect_uri
, thus causing infinite redirects.
精彩评论