开发者

Facebook requests 2.0 filter

开发者 https://www.devze.com 2023-02-17 01:24 出处:网络
So I hope someone call help me with this issue as I\'m not too sure if its javascript, or if its facebook.

So I hope someone call help me with this issue as I'm not too sure if its javascript, or if its facebook.

Here's my situation. I upgraded to Requests 2.0 on facebook, which no longer gives me the ability to add an exclude_ids field to the form where users will invite their f开发者_Python百科riends to the App. The purpose of this form is not to just invite friends, but to add friends as something in the App.

In short, I have a list of friends that they have already added, and I want to filter that from the master list of their friends so that when they want to use the form, the friends already added do not show up.

Here is my javascript to get the friends:

<script language="Javascript" type="text/javascript">    
var friends_filter = '<?=$myClass->getFiltered());?>';
</script>

Will return something like:

999999999,999999999,999999999,999999999,999999999,999999999,999999999

Which is a list of IDs of the users who they have NOT added that are their friends.

Here is my code for the form:

function addUser() {
    FB.ui(
    {
        method: 'apprequests',
        display: 'dialog',
        title: 'Add friends',
        message: 'Hey, I added you as a user/friend on such-and-such App', 
        data: 'added',
        filters: [{name: 'Non-Added', user_ids: [friends_filter]}],
    },
    function(response) {
        if(response && response.request_ids) {
            showLoading('Adding Relatives');
            var dataString = 'rids='+response.request_ids;
            $.ajax({
                type: "GET",
                url: server_url+"ajax/add_relative.php",
                data: dataString,
                success: function(data){
                    window.location.reload();
                }
            });
        }
    }
    );
}

If you look at the filters: [{name: 'Non-Added', user_ids: [friends_filter]}], line, that is where I include the list of IDS that I only want to see in the selector. The dialog pops up, but then list those ID's in friends_filter and an error message stating "does not resolve to a valid user ID"

This is where I get confused, if I copy and paste what friends_filter outputs and replace it the friends_filter with the list of IDs, i.e. 999999999,999999999,999999999,999999999, exactly as it appears, it works correctly.

I know this is an exhaustive post and I'm sorry, but I'm at my wits end.

The only thing I could think of is that perhaps my javascript variable friends_filter needs to be converted to some type of some sort?

Any ideas?


i was try this code and it is work good with me

      FB.ui(
           {
             method: 'apprequests',
             filters: ['app_non_users'],
             message: 'msg here!',
            title: 'title for box'
           },
           function(response) {
               alert(response.request_ids);//this is return after send invite
           }
         );

just if you want filter result with list of user use

filters: [{name: 'Invite friends', user_ids: <?php echo json_encode($users_array);?> }],


After much trial and error, I figured out the solution.

in:

<script language="Javascript" type="text/javascript">    
var friends_filter = '<?=$myClass->getFiltered());?>';
</script>

I changed to

<script language="Javascript" type="text/javascript">    
var friends_filter = [<?=$myClass->getFiltered());?>];
</script>

By replacing the quotes around the php echo with brackets.

Then I changed:

filters: [{name: 'Non-Added', user_ids: [friends_filter]}],

To:

filters: [{name: 'Non-Added', user_ids: friends_filter}],


If you want to exclude those (of your friends) who added the application, you simply use:

filters: ['app_non_users']
0

精彩评论

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

关注公众号