Multiple facebook apps in one web app

I am trying to use cms umbraco for several facebook applications. My idea was for each facebook application to be displayed on an aspx page in umbraco (these “applications” are very simple, just a few images, possibly a poll in each). But I can only have one facebookSettings in web.config. Is it possible to install the facebook application in web.config but set the settings in code? Or is there another way to have multiple facebook apps in one web app (umbraco)?

EDIT: I am using facebookdk 5.0.2 beta p>

+4
source share
2 answers

See Section 4 of this Prabir Blog Post for more information on setting Facebook preferences in code.

Edit: You will also want to be very careful when managing instances of FacebookClient to avoid confusion like statics, etc.

+1
source

You need to first create a new class that implements IFacebookApplication.

private class RequestScopedFacebookApplication : IFacebookApplication { private IFacebookApplication Current { get { var url = HttpContext.Current.Request.Url; var app = GetSettingsForUrl(url); return app; } } public string AppId { get { return Current.AppId; } } /* ....... */ } 

Then in Application_Start from global.asax install the facebook application.

 public void Application_Start() { FacebookApplication.SetApplication(new RequestScopedFacebookApplication()); } 

UPDATE: The following is an additional sample implementation: https://gist.github.com/820881

+7
source

Source: https://habr.com/ru/post/1338813/


All Articles