Facebook app not working for new users

221 Views Asked by At

I have developed a facebook app in node js which is hosted on heroku. It will display some of the users public data.It worked fine for two days but from the next day it is showing an application error for new users but for the users who have already used the app it is working fine.I couldn't understand where the problem lies if I run it locally using "foreman start" or "node web.js" I'm getting an " this web-page has a redirect loop" message only for new users.I have tried it by deleting all the cookies and webpage data also even then I got the same message. I'm using "facebook-node-sdk" for facebook connect and "ejs" for displaying the web-page and express for server.

App looks like this for old users

The app is hosted here

I couldn't find anything in the logs also. Can anyone help me in solving this problem.

The app code:

var express = require('express');
var Facebook = require('facebook-node-sdk');
var app = express.createServer();
var pic;
var cover;
app.configure(function () {
  app.use(express.bodyParser());
  app.use(express.cookieParser());
  app.use(express.session({ secret: 'password' }));
  app.use(Facebook.middleware({appId:'12345',secret:'12345'}));
});
app.set('view options', { layout: false });
app.set('view engine', 'ejs');
app.get('/', Facebook.loginRequired(), function (req, res) {
        req.facebook.api('/me?fields=picture.type(square)', function(err, pict) {
            pic=pict.picture.data.url;
        });
    req.facebook.api('/me?fields=cover',function(err,cover_pg){
        cover=cover_pg.cover.source;
        });
    req.facebook.api('/me', function(err, user) {
            res.render('home', {locals: {
        title:'Public-Profile', 
        user:user.name , 
            id:user.id, 
        gender:user.gender,
        hometown:user.hometown.name, 
        current:user.location.name,
        link:user.link,
        pic:pic,
        cover:cover
        }
        });
    });
}); 
var port = process.env.PORT || 5000;
app.listen(port, function() {
  console.log("Listening on " + port);
});

The ejs file code:

<html>
<head>
<title><%= title %></title>
</head>
<body>
<h3>This app is ment to show all your facebook public profile</h3>
<h3>Welcome:</h3>
<h3><img src=<%= pic %>> <%= user %>   </h3> 
<a href=<%= cover %> target="_blank"><img src=<%= cover %> height="200"></a>
<h3>Your Facebook Id:<%= id %></h3>
<h3>Gender:<%= gender %></h3>
<h3>Your home-town:<%= hometown %></h3>
<h3>Your Current-Location:<%= current %></h3>
<a href=<%= link %> target="_blank"><h2>Visit Your Profile</h2></a>
<br/><br/><br/><br/><br/><br/><br/><br/>
<p>--By Dinesh</p>
<p>This app is still under development it will be ready soon...</p>
</body>
</html>
1

There are 1 best solutions below

0
On

Here We have lot of option to configure facebook authentication .

Use Passsport.js

http://passportjs.org/

Hope this will work..