Exemplo n.º 1
0
        /// <summary>
        /// Checks the twitter authorization and performs the related ui changes
        /// </summary>
        private void checkTwitterAuth()
        {
            string accessToken;
            string accessTokenSecret;
            bool   authorized;

            try
            {
                // Set label for authorization status
                lblAuthStatusValue.Content = "Access not granted";
                accessToken       = Settings.getAccessToken();
                accessTokenSecret = Settings.getAccessTokenSecret();
                twitter           = new Twitter(accessToken, accessTokenSecret);
                if (twitter != null)
                {
                    authorized = twitter.checkAuthorization(false);
                    if (authorized == true)
                    {
                        lblAuthStatusValue.Content = "Access granted";
                        btnAuthorise.IsEnabled     = false;
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
                MessageBox.Show(e.Message);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initialize the Twitter helper class and get the Twitter access
        /// </summary>
        /// <returns>Twitter helper class</returns>
        private Twitter getTwitterAccess()
        {
            string accessToken;
            string accessTokenSecret;

            try
            {
                if (twitter == null)
                {
                    // Get saved token to perform Twitter access
                    accessToken       = Settings.getAccessToken();
                    accessTokenSecret = Settings.getAccessTokenSecret();
                    if (string.IsNullOrEmpty(accessToken) == false && string.IsNullOrEmpty(accessTokenSecret) == false)
                    {
                        twitter = new Twitter(accessToken, accessTokenSecret);
                        // Check access
                        if (twitter.checkAuthorization(false) == false)
                        {
                            twitter = null;
                        }
                        return(twitter);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(twitter);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }