我可以使用请求对话框向50个用to=
字段修改的用户朋友发送应用请求,但我想向所有用户的朋友发送请求,例如此示例应用:Invite your friend button for pages
这个应用程序邀请用户前50位朋友再次邀请用户接下来的50位朋友等等
在我的代码中,我使用PHP将用户转发到此URL
https://www.facebook.com/dialog/apprequests?app_id=443468799026324
&to=" . $friend_ids . "
&max_recipients=50&filters=app_non_users
&redirect_uri=" . urlencode($canvas_page2) . "
&message=" . $message;
Facebook offical guide for request dialogue
我如何从这里开始?
答案 0 :(得分:4)
您可以按照以下方式执行此操作: 首先,当您发送请求时,将50个朋友ID设置为参数并在cookie中存储剩余的朋友ID,然后重定向到您的网站网址,您可以在其中重复上述步骤.i.e。发送50个朋友请求和存储在cookie中。
var to="";
for(var j=0 ; j< 50 && j<friends.length ; j++){
if(friends[j].checked == true){
to += friends[j].value;
if(j != friends.length-1 && j != 49){
to += ',';
}
}
}
var redirect_uri=your_site_url+"?button=inviteresponse";
var callbackto="";
for(var i=j;i<friends.length;i++){
callbackto += friends[i].value;
if(i != friends.length-1){
callbackto += ',';
}
}
document.cookie = "param="+callbackto+";path=/";
var url="https://www.facebook.com/dialog/apprequests?app_id="+app_id+"&to="+to+"&message=Checkout apps&redirect_uri="+redirect_uri;
window.open(url,'', 'width=900,height=500,resizable=yes,scrollbars=yes');
case "inviteresponse":
if (empty($_COOKIE['param'])) {
unset($_COOKIE['param']);
echo "<script type='text/javascript'>window.close();</script>";
die();
} else {
$friends = explode(",", $_COOKIE["param"]);
$to = "";
for ($j = 0; $j < 50 && $j < count($friends); $j++) {
$to .= $friends[$j];
if ($j != count($friends) - 1 && $j != 49) {
$to .= ",";
}
}
$redirect_uri = your_site_url+"?button=inviteresponse";
$callbackto = "";
for ($i = $j; $i < count($friends); $i++) {
$callbackto .= $friends[$i];
if ($i != count($friends) - 1) {
$callbackto .= ",";
}
}
unset($_COOKIE['param']);
setcookie("param", $callbackto);
$url = "https://www.facebook.com/dialog/apprequests?app_id=" . APP_ID . "&to=" . $to . "&message=Checkout apps&redirect_uri=" . $redirect_uri;
header("Location: " . $url);
}