Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用Node.js在Facebook上发布?_Javascript_Facebook_Node.js - Fatal编程技术网

Javascript 如何使用Node.js在Facebook上发布?

Javascript 如何使用Node.js在Facebook上发布?,javascript,facebook,node.js,Javascript,Facebook,Node.js,我刚开始摆弄Node.js和它的模块export和passport。在为Facebook设置登录后,我被困了好几个小时,不知道如何在我的应用程序中发布帖子。我已经在Facebook开发者上注册了应用程序,以获取其应用程序ID和应用程序机密。我还将其注册到localhost。我现在如何在Facebook上发布 这是我目前的代码: var passport = require('passport') , FacebookStrategy = require('passport-facebook'

我刚开始摆弄Node.js和它的模块export和passport。在为Facebook设置登录后,我被困了好几个小时,不知道如何在我的应用程序中发布帖子。我已经在Facebook开发者上注册了应用程序,以获取其应用程序ID和应用程序机密。我还将其注册到localhost。我现在如何在Facebook上发布

这是我目前的代码:

var passport = require('passport')
  , FacebookStrategy = require('passport-facebook').Strategy;

passport.use(new FacebookStrategy({
    clientID:   APP_ID,
    clientSecret:   APP_SECRET,
    callbackURL: "http://localhost:3000/"
  },
  function(accessToken, refreshToken, profile, done) {
    /*
    User.findOrCreate(..., function(err, user) {
      if (err) { return done(err); }
      done(null, user);
    });
    */
  }
));


var express = require('express');
var app = express();

app.get('/', function(req, res){
  res.send('hello world <a href="/auth/facebook">Login with Facebook</a>');
});

app.listen(3000);


// Redirect the user to Facebook for authentication.  When complete,
// Facebook will redirect the user back to the application at
//     /auth/facebook/callback
app.get('/auth/facebook', passport.authenticate('facebook'));

// Facebook will redirect the user to this URL after approval.  Finish the
// authentication process by attempting to obtain an access token.  If
// access was granted, the user will be logged in.  Otherwise,
// authentication has failed.
app.get('/auth/facebook/callback', 
  passport.authenticate('facebook', { successRedirect: '/',
                                      failureRedirect: '/login' }
                        )
);

这个代码变量是token,对吗?

我曾经使用过fb模块,它非常容易使用。非常直截了当。 npm安装fb

http://localhost:3000/?code=AQAbQE...