You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Set index route
app.get('/', utils.accesslog, function(req, res){
//Get token from session to allow post
graph.setAccessToken(req.session.fb_token);
console.log(req.session.fb_token);
var wallPost = {
message: "Hello!"
};
// To post you need to authorize the applicationt to public_stream: http://facebook.com/authorize.php?api_key=MYAPPAPIKEY&v=1.0&ext_perm=publish_stream
graph.post(req.session.fb_userId + "/feed", wallPost, function(err, results) {
// returns the post id
if (err){
console.log(JSON.stringify(err)); // { id: xxxxx}
}else {console.log(JSON.stringify(results));}
});
res.render('index', {connected: req.session.connected, title: configuration.Params.title, message: [{msg: "Hello" + req.session.fb_userId}]});
});
// Set facebook login path. On Facebook main parameter page set url as: mysite.tld/fblogin
app.get('/fblogin', utils.accesslog, function(req, res){
// we don't have a code yet
// so we'll redirect to the oauth dialog
if (!req.query.code) {
var authUrl = graph.getOauthUrl({
"client_id": configuration.Params.facebook_appId,
"redirect_uri": configuration.Params.facebook_redirect_uri
});
if (!req.query.error) { //checks whether a user denied the app facebook login/permissions
res.redirect(authUrl);
} else { //req.query.error == 'access_denied'
res.send('access denied');
}
return;
}
// code is set
// we'll send that and get the access token
graph.authorize({
"client_id": configuration.Params.facebook_appId,
"redirect_uri": configuration.Params.facebook_redirect_uri,
"client_secret": configuration.Params.facebook_secret,
"code": req.query.code
}, function (err, facebookRes) {
console.log(facebookRes);
req.session.fb_token = facebookRes.access_token;
// Get user information and put them into session
graph.get("me", function(err, user) {
req.session.fb_userId = user.id;
console.log(user); // { id: '4', name: 'Mark Zuckerberg'... }
res.redirect('/');
});
});
});```
I have two duplicate message to facebook:
{"id":"1657787844_3625402647858"}
{"message":"(#506) Duplicate status message","type":"OAuthException","code":506,"error_data":{"kError":1455006}}
It seems that pages is refreshed twice, probably i wrote something bad.
Had someone the same problem?
Thanks for your time.
Best regards.
The text was updated successfully, but these errors were encountered:
Hi, i've this code:
The text was updated successfully, but these errors were encountered: