title: Get public feeds of a Facebook Page in Node.js
body: <p>I'm developing a simple node/express/jade website that fetch all the public feeds of a Facebook Page.</p>
  
  <p>I create an application from wich i get client_id (APP_ID) and client_secret (APP_SECRET).</p>
  
  <p>My code works, and it's okay but i wonder if this is the correct way of handling this need.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>var https = require('https'),
      concat = require('concat-stream'),
      async = require('async');
  
  function FacebookPage(pageId) {
      if (!(this instanceof FacebookPage))
          return new FacebookPage(pageId);
  
      this.pageId = pageId;
  }
  
  FacebookPage.prototype.getPublicFeeds = function (callback) {
  
  var pageId = this.pageId;
  
  async.waterfall([
  
    function (done) {
          var params = {
              hostname: 'graph.facebook.com',
              port: 443,
              path: '/oauth/access_token?client_id=MY_CLIENT_ID&amp;' +
                  'client_secret=MY_CLIENT_SECRET&amp;grant_type=client_credentials',
              method: 'GET'
          };
  
          https.get(params, function (response) {
              //response is a stream so it is an EventEmitter
              response.setEncoding("utf8");
  
              //More compact
              response.pipe(concat(function (data) {
                  done(null, data);
              }));
  
              response.on("error", done);
          });
    },
  
    function (access_token, done) {
  
          var params = {
              hostname: 'graph.facebook.com',
              port: 443,
              path: '/v2.0/' + pageId + '/feed?' + access_token,
              method: 'GET'
          };
  
          https.get(params, function (response) {
              //response is a stream so it is an EventEmitter
              response.setEncoding("utf8");
  
              //More compact
              response.pipe(concat(function (data) {
                  callback(null, JSON.parse(data));
              }));
  
              response.on("error", callback);
          });
  
    }]);
  };
  
  module.exports = FacebookPage;
  </code></pre>
  
  <p>EDIT: thank to @Tobi I can delete the part of getting the access_token by putting access_token=app_id|app_secret as explained here:
  <img src="https://i.stack.imgur.com/ub504.png" alt="enter image description here"></p>