daredevil1234
daredevil1234

Reputation: 1425

Facebook Graph All Mutual Friends

I have a an app that shows mutual friends. On my node server, i have the following code to get mutual friends for my users:

var express = require('express'),
 FB = require('fb'),
 appFB = FB.extend({appId: '<appId>', appSecret:'<app-secret>'}),
 router = express.Router();

router.get("/allMutualFriends", function(req, res) {
if(!req.query.accessToken || !req.query.otherUserId){
    res.set("type", "error");
    return res.status(400).send({"accessToken":req.query.accessToken, "otherUserId": req.query.otherUserId});
}
console.log(req.query);
var accessToken = req.query.accessToken;
var otherUserId = req.query.otherUserId;
appFB.setAccessToken(accessToken);
appFB.api('/' + otherUserId, { fields: 'context.fields(all_mutual_friends.limit(500))'}, function (response) {
    if(!response.context) {
        res.set('Content-Type', 'text/plain');
        return res.status(400).send(JSON.stringify(response));
    }
  if(!response.context.all_mutual_friends) return res.status(400).send("unable to find mutual friends");
  console.log(response);
    var friends = response.context.all_mutual_friends.data;
    var responseData = [];
    for(var i = 0; i < friends.length; ++ i){
        responseData.push({name: friends[i].name, id: friends[i].id, picture: friends[i].picture.data.url});
    }
return res.status(200).send(responseData);
    });
});
module.exports = router;

I have already submitted my app to facebook and they approved it, and this chunk of code was working correctly for about a week.

However, this past Friday it stopped working completely. I am not sure if something is going on with Facebook or my code.

Now instead, all I am getting is:

{
  "context": {
    "id": "<some-large-hash>"
  },
  "id": "<the-id-of-the-other-user>"
}

The only thing I can think of is if they think my node server is my client, but it is not.

Anyone have any ideas? Api version 2.9

My apologies if this is a repeat

Upvotes: 4

Views: 644

Answers (1)

Will Chen
Will Chen

Reputation: 68

The same issue happened to me and I wasted two hours and then discovered that this is a confirmed bug with Facebook's platform API (https://developers.facebook.com/bugs/241586859664764/). Looks like many other developers have been affected by this.

P.S. I don't know why you got down-voted. This was a good question with plenty of context.

Upvotes: 5

Related Questions