0
我已經在節點js上開發了一個Facebook應用程序,該應用程序託管在heroku上。它會顯示一些用戶的公共數據。它運行良好兩天,但從第二天開始,它顯示新用戶的應用程序錯誤,但對於已經使用該應用程序的用戶來說,它工作正常。我無法理解問題在於如果我使用「foreman start」或「node web.js」在本地運行它,我得到一個「這個網頁有一個重定向循環」的消息只對新用戶。我試過了,通過刪除所有的cookies和網頁數據,即使如此,我也得到了同樣的信息。 我使用「facebook-node-sdk」作爲facebook連接,「ejs」用於顯示網頁並表達爲服務器。Facebook應用程序不爲新用戶工作
我無法找到日誌中還什麼。 任何人都可以幫助我解決這個問題。
的應用代碼:
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);
});
的EJS文件代碼:
<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>
我想你已經把它保持,怎麼把ü沒有找到代碼,所以我已經添加了code.If它註冊概述的描述讓我知道我會提供所需的細節。 –