Esempio n. 1
0
        private async void FaceBookPanel_Tapped(object sender, TappedRoutedEventArgs e)
        {
            FBSession sess = FBSession.ActiveSession;

            sess.FBAppId  = "1836050649967083";
            sess.WinAppId = "s-1-15-2-4077727447-3229361925-2416648694-1706077684-1728342750-3868544593-3947295911";
            List <string> permissionList = new List <string>();

            permissionList.Add("public_profile");
            permissionList.Add("email");

            FBPermissions permissions = new FBPermissions(permissionList);
            var           result      = await sess.LoginAsync(permissions);

            if (result.Succeeded)
            {
                App.OuiApp.fbUser           = new facebookUser();
                App.OuiApp.fbUser.email     = sess.User.Email;
                App.OuiApp.fbUser.firstName = sess.User.FirstName;
                App.OuiApp.fbUser.lastName  = sess.User.LastName;
                App.OuiApp.fbUser.gender    = sess.User.Gender;
                Frame.Navigate(typeof(ModeSelectionPage));
                // App.OuiApp.fbUser.Image = sess.User.Picture;
            }
        }
Esempio n. 2
0
        private async void login_Click(object sender, RoutedEventArgs e)
        {
            FBSession clicnt = FBSession.ActiveSession;

            clicnt.WinAppId = "s-1-15-2-3519449986-424852128-1301220477-1625817896-4185431776-1950452228-152039786";
            clicnt.FBAppId  = "1776174319303320";
            FBPermissions permissions = new FBPermissions(requested_permissions);
            FBResult      result      = await clicnt.LoginAsync(permissions);

            if (result.Succeeded && clicnt.LoggedIn)
            {
                Debug.WriteLine(result.Object);

                Debug.WriteLine(result.Succeeded);
                // login.Content = "Logout";
                IsLogged.Text = "Logged in";
                Debug.WriteLine(clicnt.User.Gender);

                Debug.WriteLine(clicnt.User.FirstName);
                Debug.WriteLine(clicnt.User.LastName);
                SquarePicture.UserId = clicnt.User.Id;
            }
            else
            {
                Debug.WriteLine(result.ErrorInfo);
            }
            //string mail = clicnt.User.Email;
            //Debug.Write(mail);
            //await clicnt.LogoutAsync();
            //Debug.WriteLine(result.Succeeded);
        }
Esempio n. 3
0
        private async void login_Click(object sender, RoutedEventArgs e)
        {
            FBSession clicnt = FBSession.ActiveSession;

            clicnt.WinAppId = "s-1-15-2-2570658695-634084948-1695579385-2199792897-657639375-2101869116-1835229594";
            clicnt.FBAppId  = "1819087251640431";
            FBPermissions permissions = new FBPermissions(requested_permissions);
            FBResult      result      = await clicnt.LoginAsync(permissions);

            if (result.Succeeded && clicnt.LoggedIn)
            {
                IsLogged.Text = "Successfully logged in";
                Debug.WriteLine(clicnt.User.Id);
                Debug.WriteLine(clicnt.User.Email);
                Debug.WriteLine(clicnt.User.FirstName);
                Debug.WriteLine(clicnt.User.LastName);
                setSession();
            }
            else
            {
                Debug.WriteLine(result.ErrorInfo);
            }
            try
            {
                var vault = new Windows.Security.Credentials.PasswordVault();
                vault.Add(new Windows.Security.Credentials.PasswordCredential(
                              "My App", clicnt.User.Name, clicnt.User.Id));
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
        private async void FacebookButton_Click(object sender, RoutedEventArgs e)
        {
            FBSession sess = FBSession.ActiveSession;

            sess.FBAppId = "1667835350097099";

            sess.WinAppId = "S-1-15-2-402772943-4257055698-2726507914-3453098009-221101651-2929789630-257638726";

            List <string> permissionList = new List <string>();

            permissionList.Add("public_profile");
            permissionList.Add("user_friends");
            permissionList.Add("user_photos");
            permissionList.Add("publish_actions");
            FBPermissions permissions = new FBPermissions(permissionList);

            FBResult result = await sess.LoginAsync(permissions);

            if (result.Succeeded)
            {
                FBUser user = sess.User;
                Debug.WriteLine("success");

                Debug.WriteLine(user.FirstName);
                Debug.WriteLine(user.LastName);
                Debug.WriteLine(user.Link);
                //  user.Id;
                // UserImage.Fill = Utils.ImageUtils.UrlToFillSource(user.Picture.Data.Url);
            }
            else
            {
                Debug.WriteLine("Fail");
            }
        }
Esempio n. 5
0
        // Setup for sharing to facebook
        // Adapted from http://microsoft.github.io/winsdkfb/sample/
        private async void MainLogin_Click(object sender, RoutedEventArgs e)
        {
            FBSession sess = FBSession.ActiveSession;

            sess.FBAppId  = "<223139641423993>";
            sess.WinAppId = "<s-1-15-2-3097751537-2617460156-63370106-2036095025-3786947386-1211125068-2096569086>";
            List <String> permissionList = new List <String>();

            permissionList.Add("public_profile");
            permissionList.Add("user_friends");
            permissionList.Add("user_likes");
            permissionList.Add("user_location");
            permissionList.Add("user_photos");
            permissionList.Add("publish_actions");
            FBPermissions permissions = new FBPermissions(permissionList);

            // Login to Facebook
            FBResult result = await sess.LoginAsync(permissions);

            if (result.Succeeded)
            {
                FBUser user = sess.User;
                Debug.WriteLine(sess.User.Id);
                Debug.WriteLine(sess.User.Name);
            }
            else
            {
                //Login failed
            }
        }
        private async void FacebookButton_Click(object sender, RoutedEventArgs e)
        {
            FBSession sess = FBSession.ActiveSession;
            sess.FBAppId = "1667835350097099";
            
            sess.WinAppId = "S-1-15-2-402772943-4257055698-2726507914-3453098009-221101651-2929789630-257638726";

            List<string> permissionList = new List<string>();
            permissionList.Add("public_profile");
            permissionList.Add("user_friends");
            permissionList.Add("user_photos");
            permissionList.Add("publish_actions");
            FBPermissions permissions = new FBPermissions(permissionList);

            FBResult result = await sess.LoginAsync(permissions);

            if (result.Succeeded)
            {
                 FBUser user = sess.User;
                Debug.WriteLine("success");

                Debug.WriteLine(user.FirstName);
                Debug.WriteLine(user.LastName);
                Debug.WriteLine(user.Link);
              //  user.Id;
               // UserImage.Fill = Utils.ImageUtils.UrlToFillSource(user.Picture.Data.Url);
            }
            else
            {
                Debug.WriteLine("Fail");
            }
        }
Esempio n. 7
0
        private async void FBRegisterButton_Click(object sender, RoutedEventArgs e)
        {
            FBSession clicnt = FBSession.ActiveSession;

            clicnt.WinAppId = "s-1-15-2-2570658695-634084948-1695579385-2199792897-657639375-2101869116-1835229594";
            clicnt.FBAppId  = "1819087251640431";
            FBPermissions permissions = new FBPermissions(requested_permissions);
            FBResult      result      = await clicnt.LoginAsync(permissions);

            if (result.Succeeded && clicnt.LoggedIn)
            {
                Debug.WriteLine(clicnt.User.Id);
                Debug.WriteLine(clicnt.User.Email);
                Debug.WriteLine(clicnt.User.FirstName);
                Debug.WriteLine(clicnt.User.LastName);
                getFBUserInfo();
                //User user = getFBUserDetails(clicnt.User);
                //addUser(user);
                //SquarePicture.UserId = clicnt.User.Id;
            }
            else
            {
                Debug.WriteLine(result.ErrorInfo);
            }
        }
Esempio n. 8
0
        public async Task Login()
        {
            if (checkInternetConnection())
            {
                // Get active session
                sess = FBSession.ActiveSession;
                if (!sess.LoggedIn)
                {
                    sess.FBAppId = "438902522960732";
                    sess.WinAppId = "3779de4318934fee8f4d5d3a4411481a";

                    // Add permissions required by the app
                    List<String> permissionList = new List<String>();
                    permissionList.Add("public_profile");
                    permissionList.Add("user_friends");
                    permissionList.Add("user_likes");
                    //permissionList.Add("user_groups");
                    permissionList.Add("user_location");
                    //permissionList.Add("user_photos");
                    permissionList.Add("publish_actions");

                    FBPermissions permissions = new FBPermissions(permissionList);

                    // Login to Facebook
                    FBResult result = await sess.LoginAsync(permissions);

                    if (result.Succeeded)
                    {
                        fbUser = sess.User;

                        //Read the user information
                        string userName = fbUser.Name;
                        string userFirstname = fbUser.FirstName;
                        string userLastname = fbUser.LastName;

                        string userGender = fbUser.Gender;
                        int userTimezone = fbUser.Timezone;

                        FBProfilePictureData userPicture = fbUser.Picture;
                    }
                    else
                    {
                        fbUser = null;
                    }
                }
                else
                {
                    fbUser = sess.User;
                }
            }
            else
            {
                noInternet = true;
                fbUser = null;
            }
        }
        /// <summary>
        /// Initialize underlying provider with relevant token information.
        /// </summary>
        /// <param name="appId">Application ID (Provided by Facebook developer site)</param>
        /// <param name="requiredPermissions">List of required required permissions. public_profile and user_posts permissions will be used by default.</param>
        /// <param name="windowsStoreId">Windows Store SID</param>
        /// <returns>Success or failure.</returns>
        public bool Initialize(string appId, FacebookPermissions requiredPermissions = FacebookPermissions.PublicProfile | FacebookPermissions.UserPosts, string windowsStoreId = null)
        {
            if (string.IsNullOrEmpty(appId))
            {
                throw new ArgumentNullException(nameof(appId));
            }

            if (string.IsNullOrEmpty(windowsStoreId))
            {
                windowsStoreId = WindowsStoreId;
            }

            isInitialized = true;

            Provider.FBAppId  = appId;
            Provider.WinAppId = windowsStoreId;

            // Permissions
            var permissionList = new List <string>();

            foreach (FacebookPermissions value in Enum.GetValues(typeof(FacebookPermissions)))
            {
                if ((requiredPermissions & value) != 0)
                {
                    var name      = value.ToString();
                    var finalName = new StringBuilder();

                    foreach (var c in name)
                    {
                        if (char.IsUpper(c))
                        {
                            if (finalName.Length > 0)
                            {
                                finalName.Append('_');
                            }

                            finalName.Append(char.ToLower(c));
                        }
                        else
                        {
                            finalName.Append(c);
                        }
                    }

                    permissionList.Add(finalName.ToString());
                }
            }

            permissions = new FBPermissions(permissionList);

            return(true);
        }
Esempio n. 10
0
        /*Facebook LogIn Authorization/Permissions
         */
        private async void OnLogin()
        {
            string Sid = WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString();

            session = FBSession.ActiveSession;

            session.WinAppId = Sid;                             //not used (only for windows 8 phone etc)
            session.FBAppId  = FB_API_KEY;                      //AppId From App Created on facebook

            List <String> permissionList = new List <String>(); //list of all the permissions needed from the user

            permissionList.Add("public_profile");
            permissionList.Add("user_location");
            permissionList.Add("user_photos");

            FBPermissions permissions = new FBPermissions(permissionList);

            var result = await session.LoginAsync(permissions);

            if (result.Succeeded)
            {
                string name = session.User.Name;
                OnSuccessLogin();//once the user has given permission and logged on
            }
            else
            {
                MessageDialog dialog = new MessageDialog("1) Re-check Credentials \n2) Check your internet connection.\n\n YES To Retry\n NO To Quit");
                dialog.Title = "Error Logging In";
                dialog.Commands.Add(new UICommand("Yes")
                {
                    Id = 0
                });

                dialog.Commands.Add(new UICommand("No")
                {
                    Id = 1
                });
                dialog.DefaultCommandIndex = 0;
                dialog.CancelCommandIndex  = 1;

                var messagResult = await dialog.ShowAsync();

                if ((int)messagResult.Id == 0)//If log out was yes, log out otherwise do nothing
                {
                    LogOut();
                }
                else
                {
                    CloseApp();
                }
            }
        }
Esempio n. 11
0
 protected bool canPublish()
 {
     if (FBPermissions.HavePublishActions)
     {
         return(true);
     }
     else
     {
         FBPermissions.PromptForPublish();
         print("can'tPublish");
         return(false);
     }
 }
        public async void Login()
        {
            var requestedPermissions = new[] { "public_profile", "email", "user_friends" };

            FBSession currentSession = FBSession.ActiveSession;

            currentSession.WinAppId = WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString();
            currentSession.FBAppId  = "469988747194991";

            FBPermissions permissions = new FBPermissions(requestedPermissions);
            FBResult      result      = await currentSession.LoginAsync(permissions);

            IsLogged = true;
        }
        public void initializeFbSession(String AppID, ICallback errorCallback, ICallback successCallback)
        {
            _session          = FBSession.ActiveSession;
            _session.WinAppId = SID;
            _session.FBAppId  = AppID;

            List <string> permissionList = new List <string>();

            permissionList.Add("public_profile");
            permissionList.Add("email");

            _permissions = new FBPermissions(permissionList);
            successCallback.Invoke("Initialized");
        }
Esempio n. 14
0
        FBPermissions BuildPermissions(
            )
        {
            FBPermissions result = null;
            List <string> perms  = new List <string>();

            for (uint i = 0; i < requested_permissions.Length; i++)
            {
                perms.Add(requested_permissions[i]);
            }

            result = new FBPermissions(perms);

            return(result);
        }
Esempio n. 15
0
        async private void FBLoginButton_Click(object sender, RoutedEventArgs e)
        {
            FBSession sess = FBSession.ActiveSession;

            sess.FBAppId  = "1836050649967083";
            sess.WinAppId = "s-1-15-2-4077727447-3229361925-2416648694-1706077684-1728342750-3868544593-3947295911";
            List <string> permissionList = new List <string>();

            permissionList.Add("public_profile");
            permissionList.Add("email");

            FBPermissions permissions = new FBPermissions(permissionList);
            var           result      = await sess.LoginAsync(permissions);

            if (result.Succeeded)
            {
                string name = sess.User.Name;
            }
        }
        // Define a method that performs the authentication process
        // using a Facebook sign-in.
        private async Task AuthenticateAsync()
        {
            prgBusy.IsActive = true;
            FBSession sess = FBSession.ActiveSession;

            sess.FBAppId  = ConfigSecrets.FacebookAppID;
            sess.WinAppId = ConfigSecrets.WindowsStoreID;

            List <String> permissionList = new List <String>();

            permissionList.Add("public_profile");
            FBPermissions permissions = new FBPermissions(permissionList);

            // Login to Facebook
            FBResult result = await sess.LoginAsync(permissions);

            user = sess.User;

            if (result.Succeeded)
            {
                if (sess.LoggedIn)
                {
                    userUniqueID = user.Name;
                    isLoggedin   = true;
                    await SetUIState(true);

                    var message = string.Format("Logged in as {0}", userUniqueID);
                    TextUserName.Text = message;

                    insertUser(userUniqueID);
                }
                else
                {
                    await UpdateStatus("Please login to chat with others", true);
                }
            }
            else
            {
                await UpdateStatus("Please login to chat with others", false);
            }
            prgBusy.IsActive = false;
        }
Esempio n. 17
0
        public async Task<string> LogIntoFacebook()
        {
            //getting application Id
            string SID = WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString();

            // Get active session
            FBSession sess = FBSession.ActiveSession;
            sess.FBAppId = Constants.FacebookAppId;
            sess.WinAppId = SID;

            //setting Permissions
            FBPermissions permissions = new FBPermissions(PermissionList);

            try
            {
                // Login to Facebook
                FBResult result = await sess.LoginAsync(permissions);

                if (result.Succeeded)
                {
                    // Login successful
                    return sess.AccessTokenData.AccessToken;
                }
                else
                {
                    // Login failed
                    return null;

                }
            }
            catch (InvalidOperationException ex)
            {
                //error handling
                return null;
            }
            catch (Exception ex)
            {
                //error handling
                return null;
            }
        }
Esempio n. 18
0
        public async Task <string> LogIntoFacebook()
        {
            //getting application Id
            string SID = WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString();

            // Get active session
            FBSession sess = FBSession.ActiveSession;

            sess.FBAppId  = Constants.FacebookAppId;
            sess.WinAppId = SID;

            //setting Permissions
            FBPermissions permissions = new FBPermissions(PermissionList);

            try
            {
                // Login to Facebook
                FBResult result = await sess.LoginAsync(permissions);

                if (result.Succeeded)
                {
                    // Login successful
                    return(sess.AccessTokenData.AccessToken);
                }
                else
                {
                    // Login failed
                    return(null);
                }
            }
            catch (InvalidOperationException ex)
            {
                //error handling
                return(null);
            }
            catch (Exception ex)
            {
                //error handling
                return(null);
            }
        }
Esempio n. 19
0
        private void Login(List <string> permissionsList, IPromise promise)
        {
            var session = FBSession.ActiveSession;

            session.FBAppId  = _fbAppId;
            session.WinAppId = _winAppId;
            var permissions = new FBPermissions(permissionsList);

            RunOnDispatcher(async() =>
            {
                var result = await session.LoginAsync(permissions, SessionLoginBehavior.WebAuth);
                if (result.Succeeded)
                {
                    promise.Resolve(CreateLoginResponse(session));
                }
                else
                {
                    promise.Reject(result.ErrorInfo.Message);
                }
            });
        }
Esempio n. 20
0
        private async void fbLoginBtn_Click(object sender, RoutedEventArgs e)
        {
            FBSession session = FBSession.ActiveSession;

            session.WinAppId = SId;
            session.FBAppId  = AppId;
            //List<string> permissionList = new List<string>();
            //permissionList.Add("public_profile");
            //permissionList.Add("email");
            FBPermissions permissions = new FBPermissions(requested_permissions);
            var           result      = await session.LoginAsync(permissions);

            if (result.Succeeded)
            {
                string name = session.User.Name;
                Debug.WriteLine(session.User.Id);
                Debug.WriteLine(session.User.Name);
                Frame.Navigate(typeof(EventMainPage));
            }
            else
            {
                //Login failed
            }
        }
Esempio n. 21
0
        private void Login(List<string> permissionsList, IPromise promise)
        {
            var session = FBSession.ActiveSession;
            session.FBAppId = _fbAppId;
            session.WinAppId = _winAppId;
            var permissions = new FBPermissions(permissionsList);

            RunOnDispatcher(async () =>
            {
                var result = await session.LoginAsync(permissions, SessionLoginBehavior.WebAuth);
                if (result.Succeeded)
                {
                    promise.Resolve(CreateLoginResponse(session));
                }
                else
                {
                    promise.Reject(result.ErrorInfo.Message);
                }
            });
        }
Esempio n. 22
0
 public override void login()
 {
     FBPermissions.PromptForLogin(OnLoginAttempComplete);
     //FBPermissions.PromptForPublish(OnLoginAttempComplete);
 }
Esempio n. 23
0
        FBPermissions BuildPermissions(
            )
        {
            FBPermissions result = null;
            List<string> perms = new List<string>();

            for (uint i = 0; i < requested_permissions.Length; i++)
            {
                perms.Add(requested_permissions[i]);
            }

            result = new FBPermissions(perms);

            return result;
        }
        private async void AddFacebookButton_OnClick(object sender, RoutedEventArgs e)
        {
            var sess = FBSession.ActiveSession;
            //Use your FB App ID
            sess.FBAppId = AuthTokens.FacebookAppID;
            sess.WinAppId = WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString();


            // Add permissions required by the app
            var permissionList = new List<string> {"public_profile", "publish_actions"};
            var permissions = new FBPermissions(permissionList);


            // Login to Facebook
            var result = await sess.LoginAsync(permissions);

            if (result.Succeeded)
            {
                //TODO:
            }
            else
            {
                //TODO:
            }
        }
        private async void FacebookLoginMethod()
        {
            MessengerInstance.Send(new NotificationMessage("ProgressBarEnable"));
            var sess = FBSession.ActiveSession;
            //Use your FB App ID
            sess.FBAppId = AuthTokens.FacebookAppID;
            sess.WinAppId = WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString();
            

            // Add permissions required by the app
            var permissionList = new List<string>();
            permissionList.Add("public_profile");
            permissionList.Add("publish_actions");
            var permissions = new FBPermissions(permissionList);


            // Login to Facebook
            var result = await sess.LoginAsync(permissions);

            if (result.Succeeded)
            {
                FacebookPlusIconVisibility = Visibility.Collapsed;
                FacebookRemoveIconVisibility = Visibility.Visible;
            }
            else
            {
                
                FacebookPlusIconVisibility = Visibility.Visible;
                FacebookRemoveIconVisibility = Visibility.Collapsed;
            }
            RaisePropertyChanged(()=>FacebookPlusIconVisibility);
            RaisePropertyChanged(()=>FacebookRemoveIconVisibility);
            MessengerInstance.Send(new NotificationMessage("ProgressBarDisable"));
        }