protected void cmdUpdateStatus_Click(object sender, EventArgs e) { IUserOptionsService userOption = Sage.Platform.Application.ApplicationContext.Current.Services.Get<IUserOptionsService>(); string userName = userOption.GetCommonOption("UserName", "Twitter"); string passWord = userOption.GetCommonOption("Password", "Twitter"); if (!String.IsNullOrEmpty(userName) & !String.IsNullOrEmpty(passWord) & !String.IsNullOrEmpty(txtStatus.Text)) { try { Twitterizer.Framework.Twitter t = new Twitterizer.Framework.Twitter(userName, passWord); t.Status.Update(txtStatus.Text); } catch (Exception ex) { } } }
protected void SendMessage() { //First get your Twitter info IUserOptionsService userOption = Sage.Platform.Application.ApplicationContext.Current.Services.Get<IUserOptionsService>(); string userName = userOption.GetCommonOption("UserName", "Twitter"); string passWord = userOption.GetCommonOption("Password", "Twitter"); //Make sure we have all the info we need to send this direct message if (!String.IsNullOrEmpty(userName) & !String.IsNullOrEmpty(passWord)) { try { //Id to send message to string id = ""; if (String.IsNullOrEmpty(txtTwitterId.Text)) id = ddlTwitterIds.Text; else id = txtTwitterId.Text.Trim(); //Create and send direct message if (id != "") { if (id != "noid") { if (!String.IsNullOrEmpty(txtDirectMessage.Text)) { Twitterizer.Framework.Twitter t = new Twitterizer.Framework.Twitter(userName, passWord); t.DirectMessages.New(id, txtDirectMessage.Text); if (chkRecordMsg.Checked) { CreateHistory(id); } } else { throw new Sage.Platform.Application.ValidationException("A message is required"); } } else { throw new Sage.Platform.Application.ValidationException("A Twitter Id is required"); } } else { throw new Sage.Platform.Application.ValidationException("A Twitter Id is required"); } } catch (Exception ex) { throw new Sage.Platform.Application.ValidationException(ex.Message); } } else { throw new Sage.Platform.Application.ValidationException("Please goto user options and set your Twitter username and password"); } }