How to access Facebook friends list in Meteor?

I am new to Meteor, and I have a lot of problems with this. I found the following guide, which is the closest I found for the solution: http://www.andrehonsberg.com/article/facebook-graph-api-meteor-js

The .getFriends () function here looks promising, but I have no experience with this: https://github.com/maxkferg/meteor-facebook-collections/

I implemented the following code in client / config / config.js:

Accounts.ui.config({ requestPermissions: { facebook: ['email', 'user_friends', 'user_location', 'user_events', 'friends_events', 'friends_location', 'friends_about_me', 'user_status', 'friends_status', 'read_friendlists'], } }); 

This correctly generated a permission request at the login. (I have a problem. I get the following error: " requestPermissions error: Accounts.ui.config: cannot set requestPermissions more than once for facebook", which is odd because it points to hidden accounts_ui.js, which I don’t have access. Should I redefine this just fine? There is no mention of this error in the above guide.)

I also implemented the rest of the guide code, but nothing works. In addition, the manual seems to implement a button on the screen that causes a display of some aspect of user data (friends, messages, etc.) in the list. However, I do not want to show anything; I just want to have access to data (an array of identifiers for specific users for certain user friends would be ideal) so that I can use it for various functions in my web application.

Any help would be really appreciated!

+6
source share
1 answer

From your comment, I understand that you only care about users and email.

If you are using the accounts-facebook package for Userlogin, you already have a user email. To use the login, you must configure the service. You start this server server at startup ( more ):

 ServiceConfiguration.configurations.upsert({ {service: "facebook"}, { $set: { appId: "XXX", secret: "XXX", requestPermissions: ['user_friends'] //here you are requesting the permission to get the user friends } }); 

The next step is to get the user's friends. You can use the package for this, or you can do it manually: First you need to check if the user has allowed permission. Send a request to the Facebook API (API):

 GET /{user-id}/permissions 

Hope you get an object in the form:

 { "data": [ ..., { "permission": "user_friends", "status": "granted" } ] } 

This means that the user has given you permission to receive your friends ( more ).

In the next step, you request the Graph-API for friendly words in more detail :

 GET /v2.3/{user-id}/friendlists HTTP/1.1 Host: graph.facebook.com 

This will give you all the user's girlfriends. At the last stage, you can request all or some of the lists (for example, "Close friends", "Acquaintances") with the help of more details :

 GET /v2.3/{friendlist-id} HTTP/1.1 Host: graph.facebook.com 
+7
source

Source: https://habr.com/ru/post/981294/


All Articles