protected new void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);
            if (SPContext.Current != null && SPContext.Current.Web != null && SPContext.Current.Web.CurrentUser != null)
            {
                if (Settings != null)
                {
                    byte[] BinaryId   = SPContext.Current.Web.CurrentUser.GetBinaryId();
                    string BinaryJoin = string.Join("|", BinaryId);

                    FacebookOAuthClient client = new FacebookOAuthClient
                    {
                        AppId     = AppId,
                        AppSecret = AppSecret,
                        ReturnUri = this.Page.Request.Url.AbsoluteUri
                    };

                    if ((AuthCode == null) && (!Settings.facebook_allow && string.IsNullOrWhiteSpace(Settings.facebook_access_token)))
                    {
                        FacebookScopeCollection scope = new FacebookScopeCollection();
                        scope.Add(FacebookScope.PublishStream);
                        scope.Add(FacebookScope.PublishActions);
                        scope.Add(FacebookScope.Email);
                        scope.Add(FacebookScope.Birthday);


                        Response.Redirect(client.GetAuthorizationUrl(BinaryJoin, scope));
                    }
                    else
                    {
                        if (AuthCode != null)
                        {
                            try
                            {
                                string userAccessToken = client.GetAccessTokenFromAuthCode(AuthCode);
                                Settings.facebook_access_token = userAccessToken;
                                Settings.facebook_allow        = true;
                                Client.SetClubCloudSettings(Settings);
                            }
                            catch (Exception ex)
                            {
                                string emssage = ex.Message;
                            }
                        }
                    }
                }
            }
            else
            {
                this.pnl_facebook.Visible = false;
                this.pnl_secure.Visible   = true;
            }
        }
 /// <summary>
 /// Generates the authorization URL using the specified state and scope.
 /// </summary>
 /// <param name="state">The state to send to Facebook's OAuth login page.</param>
 /// <param name="scope">The scope of the application.</param>
 /// <returns>Returns an authorization URL based on <code>state</code> and <code>scope</code>.</returns>
 public string GetAuthorizationUrl(string state, FacebookScopeCollection scope) {
     return GetAuthorizationUrl(state, scope.ToString());
 }
 /// <summary>
 /// Generates the authorization URL using the specified state and scope.
 /// </summary>
 /// <param name="state">The state to send to Facebook's OAuth login page.</param>
 /// <param name="scope">The scope of the application.</param>
 /// <returns>Returns an authorization URL based on <code>state</code> and <code>scope</code>.</returns>
 public string GetAuthorizationUrl(string state, FacebookScopeCollection scope)
 {
     return(GetAuthorizationUrl(state, scope == null ? null : scope.ToString()));
 }