public bool SendNow(Model.IItem item, string url) { if (string.IsNullOrEmpty(url) && item != null) { url = "http://twitter.com/#!/" + AppController.Current.getAccountForId(item.accountId).Login.Username + "/statuses/" + item.Id.ToString(); } if (!string.IsNullOrEmpty(this.Username) && !string.IsNullOrEmpty(this.Password)) { API.WebHelpers.Response result; if (item == null) { result = API.WebHelpers.SendPostRequestWithBasicAuth(@"https://api.del.icio.us/v1/posts/add", new { url = url, description = url, title = url }, this.Username, this.Password, false); } else { result = API.WebHelpers.SendPostRequestWithBasicAuth(@"https://api.del.icio.us/v1/posts/add", new { url = url, description = url, title = item.Text }, this.Username, this.Password, false); } bool success = (!string.IsNullOrEmpty(result.Content) && result.Content.ToLowerInvariant().Contains("<result code=\"done\" />")); if (!success) { System.Windows.Forms.MessageBox.Show("Error sending item to del.icio.us", "del.icio.us error"); } return(success); } else { System.Windows.Forms.MessageBox.Show("Missing username or password", "Login to del.icio.us failed"); Nymphicus.UserInterface.Preferences preferences = new UserInterface.Preferences(); preferences.tabExternalServices.IsSelected = true; preferences.Show(); PasswordVerified = false; return(false); } }
public bool SendNow(Model.IItem item, string url) { try { if (string.IsNullOrEmpty(url) && item != null) { url = "http://twitter.com/#!/" + AppController.Current.getAccountForId(item.accountId).Login.Username + "/statuses/" + item.Id.ToString(); } if (this.Password != "" && this.Username != "") { API.WebHelpers.Response result; if (item != null) { result = API.WebHelpers.SendPostRequest(@"https://readitlaterlist.com/v2/add", new { username = this.Username, password = this.Password, apikey = ApiKey, url = url, title = item.Text, ref_id = item.Id }, false); } else { result = API.WebHelpers.SendPostRequest(@"https://readitlaterlist.com/v2/add", new { username = this.Username, password = this.Password, apikey = ApiKey, url = url, }, false); } result.Success = (!string.IsNullOrEmpty(result.Content) && result.Content.ToLowerInvariant() == "200 ok"); if (!result.Success) { System.Windows.Forms.MessageBox.Show("Error sending item to Pocket", result.Error); return(false); } else { return(true); } } else { System.Windows.Forms.MessageBox.Show("Missing username or password", "Login to Pocket failed"); Nymphicus.UserInterface.Preferences preferences = new UserInterface.Preferences(); preferences.tabExternalServices.IsSelected = true; preferences.Show(); PasswordVerified = false; return(false); } } catch (Exception exp) { System.Windows.Forms.MessageBox.Show("Error sending item to Pocket", exp.Message); AppController.Current.Logger.writeToLogfile("Sending to Pocket failed with exception: " + exp.Message); return(false); } }