Skip to content
This repository has been archived by the owner on Oct 31, 2021. It is now read-only.

Standalone usage requires request/response/domain, but not documented #5

Closed
uuf6429 opened this issue Aug 28, 2012 · 2 comments
Closed

Comments

@uuf6429
Copy link

uuf6429 commented Aug 28, 2012

Standalone usage works over request, response and domain, but the documentation does not mention this.

This causes various errors such as with the following code:

var fbapp = new fbsdk.Facebook({
  appId  : 'YOUR APP ID',
  secret : 'YOUR API SECRET'
});

fbapp.getLoginUrl();

Which causes an exception: "No request host available"

From what I gather, it is expected that one sets the aforementioned variables as configuration parameters like the appId and secret.
This has is the cause for a problem in my end; it would require an object per socket connection, whereas one would have been enough (the solution would be to have a different Facebook SDK instance each time).

@murvinlai
Copy link

try this:

app.post('/whatever', function(req, res) {
var fbapp = new fbsdk.Facebook({
appId : 'YOUR APP ID',
secret : 'YOUR API SECRET'
request: req,
response: res
});

});

@murvinlai
Copy link

Sample Code I have:

var fbsdk = require('facebook-sdk');

app.post( '/facebook/register', function ( req, res, next ){

    var facebook = new fbsdk.Facebook({
      appId  : cfg.fb_appId,
      secret : cfg.fb_appSecret,
      request : req,
      response: res
    }); 

    var fbInfo = {};
    if (facebook.getSession() ) {
        fbInfo.uid = facebook.getSession().uid;             // fbuid
        fbInfo.access_token = facebook.getSession().access_token;
        fbInfo.sig = facebook.getSession().sig;
        fbInfo.registration = facebook.getSignedRequest().registration;  // contain all the entries in the FB registration form.
        fbInfo.oauth_token = facebook.getSignedRequest().oauth_token;    // not necessary

    }

    ... do the rest of the stuff, like add user to local DB..etc

});

@uuf6429 uuf6429 closed this as completed Sep 22, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants