/// <summary>
        /// Handles the page load event
        /// </summary>
        /// <param name="sender">
        /// Sender object
        /// </param>
        /// <param name="e">
        /// Event args
        /// </param>
        private async void MainPageLoaded(object sender, RoutedEventArgs e)
        {
            var session = SessionStorage.Load();

            if (null != session)
            {
                this.ExpiryText.Text = string.Format("Login expires on: {0}", session.Expires.ToString());

                this.ProgressText      = "Fetching details from Facebook...";
                this.ProgressIsVisible = true;

                try
                {
                    var fb = new FacebookClient(session.AccessToken);

                    dynamic result = await fb.GetTaskAsync("me");

                    var user = new GraphUser(result);
                    user.ProfilePictureUrl = new Uri(string.Format("https://graph.facebook.com/{0}/picture?access_token={1}", user.Id, session.AccessToken));

                    this.CurrentUser = user;

                    await this.GetUserStatus(fb);
                }
                catch (FacebookOAuthException exception)
                {
                    MessageBox.Show("Error fetching user data: " + exception.Message);
                }

                this.ProgressText      = string.Empty;
                this.ProgressIsVisible = false;
            }
        }
        /// <summary>
        /// Handles the OnClick event of the UpdateStatusButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private async void UpdateStatusButton_OnClick(object sender, RoutedEventArgs e)
        {
            var session = SessionStorage.Load();

            if (null == session)
            {
                return;
            }

            this.ProgressText      = "Updating status...";
            this.ProgressIsVisible = true;

            this.UpdateStatusButton.IsEnabled = false;

            try
            {
                var fb = new FacebookClient(session.AccessToken);

                await fb.PostTaskAsync(string.Format("me/feed?message={0}", this.UpdateStatusBox.Text), null);

                await this.GetUserStatus(fb);

                this.UpdateStatusBox.Text = string.Empty;
            }
            catch (FacebookOAuthException exception)
            {
                MessageBox.Show("Error fetching user data: " + exception.Message);
            }

            this.ProgressText                 = string.Empty;
            this.ProgressIsVisible            = false;
            this.UpdateStatusButton.IsEnabled = true;
        }
Ejemplo n.º 3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var session   = SessionStorage.Load();
            Uri dialogUri = new Uri(String.Format("https://m.facebook.com/v2.1/dialog/pay?access_token={0}&redirect_uri=fbconnect%3A%2F%2Fsuccess&app_id={1}&message=YOUR_MESSAGE_HERE&display=touch", session.AccessToken, MainPage.AppId));

            //Uri dialogUri = new Uri(String.Format("https://m.facebook.com/dialog/apprequests?&access_token=CAAHrnrcZA3MoBAKuBxKqFyOANlecvU0Myc4j8HXZCyVtE3cexnITp7wZCpGk9Lyufyq0uyfThIrC0L245s4M63oFASld9MbnReKddLo8gWrjqbpVzbvdB6zG5W7sC4pkSZBhelNGOUoQjQkdb5pjwj6eygfk7XkMv7mAivCCgqR0bIx8t8rpC1wJIDJXP1xyNjUmOYf7XT60wifHnndZB&redirect_uri=https%3A%2F%2Fpratapgarh.com&app_id=540541885996234&message=YOUR_MESSAGE_HERE&display=touch", session.AccessToken));
            this.MyWebBrowser.Navigate(dialogUri);
        }