Exemple #1
0
        private void ConfigurationCheck()
        {
            bool bIsSuccess = true;

            Auth auth = new Auth();
            string query = auth.GetAccessTokenQuery(CONSUMER_KEY, CONSUMER_SECRET, AuthPanel.OAuthKey.TokenKey, AuthPanel.OAuthKey.TokenSecret,VerifyCode);

            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(query);
            req.Method = "POST";
            req.PreAuthenticate = true;
            req.Proxy = AuthPanel.Proxy;

            try
            {
                WebResponse res = req.GetResponse();
                StreamReader reader = new StreamReader(res.GetResponseStream(), Encoding.UTF8);
                string data = reader.ReadToEnd();
                reader.Close();
                res.Close();

                string szTokenKey = string.Empty;
                string szTokenSecret = string.Empty;
                #region url parse
                string[] queryset = data.Split('&');
                szTokenKey = queryset[0].Split('=')[1];
                szTokenSecret = queryset[1].Split('=')[1];
                #endregion

                AuthPanel.OAuthKey.TokenKey = szTokenKey;
                AuthPanel.OAuthKey.TokenSecret = szTokenSecret;
                bIsSuccess = true;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                bIsSuccess = false;
            }

            SaveConfiguration();

            this.Dispatcher.Invoke(DispatcherPriority.Normal, new ConfigurationCompletedDelegate(ConfigurationCompleted), bIsSuccess);
        }
Exemple #2
0
        private void ConnectionCheck(WebProxy proxy)
        {
            bool bIsSuccess = true;
            OAuthKey key = null;
            Auth auth = new Auth();
            string query = auth.GetRequestTokenQuery(CONSUMER_KEY, CONSUMER_SECRET);

            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(query);
            req.Method = "POST";
            req.PreAuthenticate = true;
            //req.Accept = "text/xml, application/xml";
            req.Proxy = proxy;

            try
            {
                WebResponse res = req.GetResponse();
                StreamReader reader = new StreamReader(res.GetResponseStream(), Encoding.UTF8);
                string data = reader.ReadToEnd();
                reader.Close();
                res.Close();

                string szTokeyKey = string.Empty;
                string szTokenSecret = string.Empty;
                #region url parse
                string[] queryset = data.Split('&');
                szTokeyKey = queryset[0].Split('=')[1];
                szTokenSecret = queryset[1].Split('=')[1];
                #endregion

                key = new OAuthKey();
                key.ConsumerKey = CONSUMER_KEY;
                key.ConsumerSecret = CONSUMER_SECRET;
                key.TokenKey = szTokeyKey;
                key.TokenSecret = szTokenSecret;

                bIsSuccess = true;
            }
            catch (Exception)
            {
                bIsSuccess = false;
            }
            this.Dispatcher.Invoke(DispatcherPriority.Normal, new ConnectionCheckCompletedDelegate(ConnectionCheckCompleted), bIsSuccess,proxy, key);
        }
Exemple #3
0
 void AuthorizeLink_MouseDown(object sender, MouseButtonEventArgs e)
 {
     Auth auth = new Auth();
     string authurl = auth.GetAuthorizeQuery(AuthPanel.OAuthKey.TokenKey, null);
     Process.Start(authurl);
 }