private Response WriteRando() { Guid password = Request.Form.password; var consumerKey = ConfigurationManager.AppSettings["consumerKey"]; var consumerSecret = ConfigurationManager.AppSettings["consumerSecret"]; var token = ConfigurationManager.AppSettings["token"]; var tokenSecret = ConfigurationManager.AppSettings["tokenSecret"]; //require a password so people don't just randomly spam this endpoint if (password == new Guid(ConfigurationManager.AppSettings["password"])) { var rando = Rando.Console.Program.GenerateRando(System.Web.HttpContext.Current.Server.MapPath("~")); var service = new TwitterService(consumerKey, consumerSecret, token, tokenSecret); service.BeginSendTweet(new SendTweetOptions {Status = rando}); } return new Response() { StatusCode = HttpStatusCode.OK }; }
private void btnAdd_Click(object sender, EventArgs e) { if (!editMode) { TwitterService service = new TwitterService("9fHcTGpQkdy25gAQ8bFmiOd67", "KBWAa7reZWDEofMkgDluIfLVk9dEaAZAOTinUFInw5k6xNGCX6"); // Step 1 - Retrieve an OAuth Request Token OAuthRequestToken requestToken = service.GetRequestToken(); // Step 2 - Redirect to the OAuth Authorization URL Uri uri = service.GetAuthorizationUri(requestToken); Process.Start(uri.ToString()); // Step 3 - Exchange the Request Token for an Access Token string verifier = "0350060"; // <-- This is input into your application by your user OAuthAccessToken access = service.GetAccessToken(requestToken, verifier); // Step 4 - User authenticates using the Access Token service.AuthenticateWith(access.Token, access.TokenSecret); var aluno = new Aluno((Turma)Enum.Parse(typeof(Turma), cbxTurma.Text), txtNome.Text, txtSobrenome.Text, int.Parse(txtIdade.Text), double.Parse(txtNota.Text), (Status)Enum.Parse(typeof(Status), cbxStatus.Text)); _alunoAplicacao.Adicionar(aluno); service.BeginSendTweet(new SendTweetOptions()); } else { var aluno = _alunoAplicacao.Buscar(_aluno.Id); aluno.Turma = (Turma)Enum.Parse(typeof(Turma), cbxTurma.Text); aluno.Nome = txtNome.Text; aluno.Sobrenome = txtSobrenome.Text; aluno.Idade = int.Parse(txtIdade.Text); aluno.Nota = double.Parse(txtNota.Text); aluno.Status = (Status)Enum.Parse(typeof(Status), cbxStatus.Text); _alunoAplicacao.Atualizar(aluno); } Close(); }