public string SetBroadcast(string key, string secret, string oAuth, string oAuthSecret, string oAuthVerifier, string list, string bodyHtml, string subject) { string result = null; try { API api = GetDataApiKeyAweber(key, secret, oAuth, oAuthSecret, oAuthVerifier); Common.Utils.Partners.Mail.Aweber.Entity.Account account = api.getAccount(); string endpoint = string.Format(Settings.createBroadcast, account.id, list); Request request = new Request { oauth_consumer_key = key, oauth_consumer_secret = secret, oauth_token = api.OAuthToken, oauth_token_secret = api.OAuthTokenSecret }; SortedList <string, string> parameters = new SortedList <string, string>(); parameters.Add("click_tracking_enabled", "True"); parameters.Add("is_archived", "True"); parameters.Add("notify_on_send", "True"); parameters.Add("body_html", bodyHtml); parameters.Add("subject", subject); request.Build(parameters, endpoint); WebClient client = new WebClient(); client.Headers["Content-type"] = "application/x-www-form-urlencoded"; result = client.UploadString(endpoint, request.Parameters); var broadcast = JsonConvert.DeserializeObject <Broadcast>(result); result = broadcast.broadcast_id; } catch (Exception e) { var messageException = telemetria.MakeMessageException(e, System.Reflection.MethodBase.GetCurrentMethod().Name); telemetria.Critical(messageException); } finally { result = result == "" ? null : result; } return(result); }
public bool ListIsValid(string idCampaign) { bool result = false; string key = string.Empty; string secret = string.Empty; string oAuth = string.Empty; string oAuthSecret = string.Empty; string oAuthVerifier = string.Empty; string listId = string.Empty; try { key = GetSetting("ApiKey", idCampaign); secret = GetSetting("Secret", idCampaign); oAuth = GetSetting("OAuth", idCampaign); oAuthSecret = GetSetting("OAuthSecret", idCampaign); oAuthVerifier = GetSetting("OAuthVerifier", idCampaign); listId = GetSetting("List", idCampaign); API api = GetDataApiKeyAweber(key, secret, oAuth, oAuthSecret, oAuthVerifier); Common.Utils.Partners.Mail.Aweber.Entity.Account account = api.getAccount(); foreach (Common.Utils.Partners.Mail.Aweber.Entity.List list in account.lists().entries) { if (list.id.ToString() == listId) { result = true; } } } catch (Exception e) { var messageException = telemetria.MakeMessageException(e, System.Reflection.MethodBase.GetCurrentMethod().Name); telemetria.Critical(messageException); } return(result); }