Facebook Graph All Mutual Friends
I have 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 already submitted my app to facebook and they approved it and this piece of code worked correctly for a week.
However, last Friday it completely stopped its work. I'm not sure if something is happening with Facebook or my code.
Now, instead, all I get is:
{
"context": {
"id": "<some-large-hash>"
},
"id": "<the-id-of-the-other-user>"
}
The only thing I can think of is that they think my node server is my client, but they are not.
Does anyone have any idea? Api version 2.9
My apologies if this is a repetition
source to share
The same thing happened to me and I spent two hours and then found that this is a confirmed bug from the Facebook Platform API ( https://developers.facebook.com/bugs/241586859664764/ ). It looks like many other developers have influenced this.
PS I don't know why you left - you voted. This was a good question with a lot of context.
source to share