How to perform common FB actions with Meteor?

What are the steps required to complete the general Facebook actions in Meteor using the accounts-facebook package? I try to get a list of friends, post on the wall and end up doing other things, but I'm not sure how to proceed.

+4
source share
2 answers

Update: Minor modifications for meteor 0.6.0

You need to use the API to help you, for example, the nodefacebook api diagram: https://github.com/criso/fbgraph

You will need to make a package. You need to create a directory called /packages and in this directory called fbgraph .

Each package requires package.js (placed in the fbgraph directory). In package.js you can use something like:

 Package.describe({ summary: "Facebook fbgraph npm module", }); Package.on_use(function (api) { api.add_files('server.js', 'server'); }); Npm.depends({fbgraph:"0.2.6"}); 

server side js - server.js

 Meteor.methods({ 'postToFacebok':function(text) { var graph = Npm.require('fbgraph'); if(Meteor.user().services.facebook.accessToken) { graph.setAccessToken(Meteor.user().services.facebook.accessToken); var future = new Future(); var onComplete = future.resolver(); //Async Meteor (help from : https://gist.github.com/possibilities/3443021 graph.post('/me/feed',{message:text},function(err,result) { return onComplete(err, result); } Future.wait(future); }else{ return false; } } }); 

Then when logging in to the client

Client side js

 Meteor.call("postToFacebook", "Im posting to my wall!", function(err,result) { if(!err) alert("Posted to facebook"); }); 

Fbgraph repo: https://github.com/criso/fbgraph

API Charts API Docs for Query List: https://developers.facebook.com/docs/reference/api/

Async (Waiting for a callback from facebook before returning data to the client): https://gist.github.com/possibilities/3443021

+7
source

Did it work for you? This shows me the error on the line Future.wait(future); as an unexpected token, expected ","

0
source

All Articles