private void pictureBox1_Click_1(object sender, EventArgs e) { try { var Login = new TwitterLogin("RKlFn8Fo0xFxM1xgcaWAg22lK", "6sIGj7PN6DqPM8a7mQ2InpCIl4syZNLImwknedenN3xpfMJkP1", true, true); Login.ShowDialog(); MessageBox.Show(Login.IsSuccessfully.ToString()); if (Login.IsSuccessfully) { try { db = new EtudiantLoginDataContext(); etudiant en = new etudiant(); en.nom = Login.UserInfo.UserName; var query = from enseignant in db.etudiants where enseignant.nom == en.nom select enseignant; List <etudiant> listeEns = query.ToList <etudiant>(); if (listeEns.Count == 0) { MessageBox.Show("aucun compte n'est lié à ce twitter !"); } else { etudiant enss = listeEns[0]; ValidatedEns.cin = enss.cin; ValidatedEns.mots_de_passe = enss.mots_de_passe; ValidatedEns.nom = enss.nom; ValidatedEns.prenom = enss.prenom; ValidatedEns.mail = enss.mail; ValidatedEns.photo = enss.photo; ValidatedEns.code_a_bar = enss.code_a_bar; ValidatedEns.NiveauEtud = enss.NiveauEtud; ValidatedEns.Année = enss.Année; Accueil_Etudiant ac = new Accueil_Etudiant(); ac.Show(); } } catch (SqlException ex) { MessageBox.Show("Erreur de connection BD " + ex.Message); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void GetAccessToken() { if (InvokeRequired) { Invoke(new Action(GetAccessToken)); return; } var login = new TwitterLogin ( Settings.ConsumerKey, Settings.ConsumerSecret //, true // auto logout ); login.Owner = this; login.ShowDialog(); if (login.IsSuccessfully) { // save access token to application settings Settings.AccessToken = ((OAuthAccessToken)login.AccessToken).Value; Settings.TokenSecret = ((OAuthAccessToken)login.AccessToken).TokenSecret; Settings.UserId = login.AccessToken["user_id"].ToString(); Settings.Save(); // get tweets GetTweets(); } else { if (MessageBox.Show("Please Click OK to login on Twitter or CANCEL for exit from the program.", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel) { Close(); } else { GetAccessToken(); } } }
private void GetAccessToken() { var login = new TwitterLogin(this.ConsumerKey, this.ConsumerSecret, loadUserInfo: true); login.Owner = this; login.ShowDialog(); if (login.IsSuccessfully) { Properties.Settings.Default.AccessToken = login.AccessTokenValue; Properties.Settings.Default.TokenSecret = ((OAuthAccessToken)login.AccessToken).TokenSecret; Properties.Settings.Default.Save(); this.Text = login.UserInfo.DisplayName ?? login.UserInfo.UserName; this.GetTweets(); } else { MessageBox.Show("error..."); } }