Unfriending someone through the Facebook API?

2020-06-19 11:00发布

问题:

Is it possible to remove a friend relationship between two FB users through the API? I'm thinking that it's not, but (if not) is it possible to at least bring up a dialog that would let the user request the unfriending, similar to how the Friends Dialog (http://developers.facebook.com/docs/reference/dialogs/friends/) lets a user send a friend invitation?

回答1:

It is not possible through the API. Facebook is like the mafia - you can get in. but there's no way out.

Simialar to this question: Any way to unfriend or delete a friend using Facebook's PHP SDK or API?

Also, it is against the terms of service for facebook apps to ask people to unfriend. There was a BurgerKing prootional app that famously ran afoul of that after going viral. http://www.insidefacebook.com/2009/01/14/whopper-sacrifice-shut-down-by-facebook/

Let friends unfriend on their own time.



回答2:

You can do that with a browser script: Deleteting All Facebook friend programmatically using fb graph api

The script in this page is out of date, here's a working one:

$.ajax({
  url: "https://graph.facebook.com/me/friends?access_token=ACCESS_TOKEN", // get this at https://developers.facebook.com/tools/explorer take the Friends link and replace it.
  success: function(data) {
        jQuery.each(data.data, function() {
            $.ajax({
                url: "https://m.facebook.com/a/removefriend.php",
                data: "friend_id="+this.id+"&fb_dtsg=AQC4AoV0&unref=profile_gear&confirm=Confirmer",
                async: false,
                type: "post"
                }
            })
        });
  },
  dataType: "json"
});