Php 为什么exclude_ids参数在facebook应用程序邀请中不起作用?

Php 为什么exclude_ids参数在facebook应用程序邀请中不起作用?,php,facebook,facebook-graph-api,Php,Facebook,Facebook Graph Api,这是我的邀请代码: <?php $app_id = "12345678910112"; $canvas_page = "http://apps.facebook.com/apppage/"; $con = new mysqli("localhost","username","password","dbname") or die(mysqli_connect_error()); $SQL=mysqli_query($con,"select the already invi

这是我的邀请代码:

<?php 
$app_id = "12345678910112";
$canvas_page = "http://apps.facebook.com/apppage/";       

$con = new mysqli("localhost","username","password","dbname") or die(mysqli_connect_error()); 
$SQL=mysqli_query($con,"select the already invited friends");

$exclude_ids="";

while($row = mysqli_fetch_assoc($SQL))
{
$exclude_ids=$exclude_ids . "," . $row['inviteduserid']  ; 
}

mysqli_free_result($SQL);
mysqli_close($con);
// now the $exclude_ids will look like this 12321324,54621321,465498631,23184641  

$message = "join this cool app";
$filters = array('app_non_users');
$requests_url = "https://www.facebook.com/dialog/apprequests?app_id=" . $app_id 
. "&redirect_uri=" . urlencode($canvas_page) 
. "&message=" . $message 
. "&filters=" . json_encode($filters) 
. "&max_recipients=25" 
. "&exclude_ids=" . $exclude_ids;
?>

除了邀请的朋友之外,一切都很顺利。
这有什么问题?

关于构建逗号分隔字符串的注意事项:如果先将它们放入数组中,这会变得更容易

$excludeIdArr=[];
$excludeIdStr="";

while($row = mysqli_fetch_assoc($SQL))
{
    $excludeIdArr[]=$row['inviteduserid']; 
}

$excludeIdStr = implode(",",$excludeIdsArr);
在ID列表的开头有一个额外的逗号

此外。。。表示exclude_ids参数采用数组

排除\u id 将从对话框中排除的用户ID数组


谢谢Lix,但我不知道为什么它对我仍然不起作用。 无论如何,我不得不绕道而行,由于排除ID不起作用,但过滤器非常完美,因此我将使用过滤器参数仅显示未邀请的朋友,如下所示

<?php 

 //get the current user id.
$signed_request = $_REQUEST["signed_request"];
list($encoded_sig, $payload) = explode('.', $signed_request, 2); 
$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);

//get the already invited friends from the database based on $data["user_id"].
    $SQL = mysqli_query($con,"select the invited users ids from the DB"); 
     $exclude_ids = $data["user_id"]; //$data["user_id"] ia my facebook id i added it to the excluded ids because i will not use app_non_users in the filter
    while($row = mysqli_fetch_assoc($SQL))
    {
        $exclude_ids = $exclude_ids . "," . $row['invto']  ;
    }
    mysqli_free_result($SQL);
    mysqli_close($con);

//get my friends.
require("php-sdk/src/facebook.php");
     $facebook = new Facebook(array('appId'  => 'APP_ID','secret' => 'APP_SECRET','cookie' => true,));

    $fbme = $facebook->api('/me/friends');
    $datas = $fbme['data'];

 foreach($datas as $x)
 {
     $arymyfriends[] = $x['id'];
 }

 //compare my friends to the invited friends and get the unmatched.
 $aryexcluded = explode(",",$exclude_ids);
 $aryresults = array_diff($arymyfriends,$aryexcluded);
 $exclude_ids = implode(",",$aryresults );


 //show the invitation page
     $app_id = "12345678912358";
     $canvas_page = "http://apps.facebook.com/appname/";
     $message = "come join this cool app.";
     $filters = array(array('name' => 'Best friends','user_ids' => $exclude_ids));
     $requests_url = "https://www.facebook.com/dialog/apprequests?app_id=" . $app_id 
     . "&redirect_uri=" . urlencode($canvas_page) 
     . "&message=" . $message 
     . "&filters=" . json_encode($filters) 
     . "&max_recipients=25";

     if (empty($_REQUEST["request_ids"])) {
        echo("<script> top.location.href='" . $requests_url . "'</script>");

     }
我知道这不是最好的解决方案,但它很有效