Multiple facebook apps under one web application

隐身守侯 提交于 2019-11-30 17:28:01

问题


I'm trying to use the umbraco cms for a few facebook apps. My idea was to have each facebook app in an aspx page in umbraco (these "apps" are very simple, only a few images, maybe a poll in each). But I can have only one facebookSettings in web.config. Is it possible to not set the facebook app in web.config but set the settings in the code behind? Or is there another way to have multiple facebook apps in one web application (umbraco)?

EDIT: I'm using facebooksdk 5.0.2 beta


回答1:


See section 4 of this post on Prabir's blog for details on how to set Facebook settings in code.

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




回答2:


You will need to first create a new class implementing 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 the Application_Start of global.asax, set your facebook application.

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

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



来源:https://stackoverflow.com/questions/4931240/multiple-facebook-apps-under-one-web-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!