本文整理汇总了C#中MailChimpManager.Subscribe方法的典型用法代码示例。如果您正苦于以下问题:C# MailChimpManager.Subscribe方法的具体用法?C# MailChimpManager.Subscribe怎么用?C# MailChimpManager.Subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MailChimpManager
的用法示例。
在下文中一共展示了MailChimpManager.Subscribe方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Send
public void Send(String idUser, String firstName, String email)
{
String emailAPI = ConfigurationManager.AppSettings["MailChimpAPI"].ToString();
MailChimpManager mc = new MailChimpManager(emailAPI);
ListResult lists = mc.GetLists();
EmailConfirm emailConfirm = new EmailConfirm();
//emailConfirm.Groupings = new List<Grouping>();
//emailConfirm.Groupings.Add(new Grouping());
//emailConfirm.Groupings[0].Id = 1234; // replace with your grouping id
//emailConfirm.Groupings[0].GroupNames = new List<string>();
//emailConfirm.Groupings[0].GroupNames.Add("Your Group Name");
emailConfirm.FirstName = firstName;
emailConfirm.IdUser = idUser;
// Create the email parameter
EmailParameter parameters = new EmailParameter()
{
Email = email
};
// ListResult lr = mc.GetLists();
EmailParameter results = mc.Subscribe("d31fd680be", parameters, emailConfirm);
}
示例2: Post
// POST api/mailchimp
public string Post(Subscriber subscriber)
{
MailChimpManager mc = new MailChimpManager(_mailchimpKey);
MyMergeVar myMergeVars = new MyMergeVar();
myMergeVars.FirstName = subscriber.FirstName;
myMergeVars.LastName = subscriber.LastName; // Create the email parameter
EmailParameter email = new EmailParameter()
{
Email = subscriber.EmailAddress
};
EmailParameter results = mc.Subscribe(_mailchimpGroupId, email, myMergeVars);
return results.LEId;
}
示例3: Subscribe_Successful
public void Subscribe_Successful()
{
// Arrange
MailChimpManager mc = new MailChimpManager(TestGlobal.Test_APIKey);
ListResult lists = mc.GetLists();
EmailParameter email = new EmailParameter()
{
Email = "[email protected]"
};
// Act
EmailParameter results = mc.Subscribe(lists.Data[1].Id, email);
// Assert
Assert.IsNotNull(results);
Assert.IsTrue(!string.IsNullOrEmpty(results.LEId));
}
示例4: Subscribe
public bool Subscribe(string email, int domainID)
{
tbl_Domains domain = DomainsRepository.GetByID(domainID);
if (domain == null || !domain.DO_EnableMailChimp)
return false;
MailChimpManager manager = new MailChimpManager(domain.DO_MailChimpAPIKey);
EmailParameter emailParam = new EmailParameter() { Email = email };
try
{
var val = manager.Subscribe(domain.DO_MailChimpListID, emailParam, updateExisting: true);
return val != null ? true : false;
}
catch (MailChimpAPIException e)
{
Log.Error(String.Format("MailChimp Subscribe: Subscription exception: \"{0}\" ,for \"{1}\"", e.MailChimpAPIError.Name, email), e);
}
return false;
}
示例5: AddSubscriber
// MailChimp campaign methods
public EmailParameter AddSubscriber(string emailAddress, string fname, string lname)
{
var list = _listId;
Models.MailChimpCampaignModel.MergeFields userFields = new Models.MailChimpCampaignModel.MergeFields();
userFields.FirstName = fname;
userFields.LastName = lname;
MailChimpManager mc = new MailChimpManager(_apiKey);
EmailParameter email = new EmailParameter()
{
Email = emailAddress
};
EmailParameter result = mc.Subscribe(list, email, userFields);
return result;
}
示例6: Subscribe
public IHttpActionResult Subscribe(string subscribeEmail)
{
EmailParameter result;
if (!string.IsNullOrEmpty(_mailingSettings.AccessToken) && !string.IsNullOrEmpty(_mailingSettings.AccessToken) && !string.IsNullOrEmpty(_mailingSettings.SubscribersListId) &&
subscribeEmail.Contains("@") && subscribeEmail.Contains("."))
{
var mc = new MailChimpManager(_mailingSettings.AccessToken, _mailingSettings.DataCenter);
// Create the email parameter
var email = new EmailParameter()
{
Email = subscribeEmail,
};
result = mc.Subscribe(_mailingSettings.SubscribersListId, email);
if (string.IsNullOrEmpty(result.EUId))
return BadRequest();
}
else
{
return BadRequest();
}
return Ok(result);
}
示例7: AddEmail
public static EmailParameter AddEmail(string email)
{
try
{
var apiKey = ConfigurationManager.AppSettings["MailChimpApiKey"];
var listId = ConfigurationManager.AppSettings["MailChimpListId"];
var mc = new MailChimpManager(apiKey);
// Create the email parameter
var emailParam = new EmailParameter()
{
Email = email
};
var result = mc.Subscribe(listId, emailParam, doubleOptIn: false);
return result;
}
catch (Exception)
{
}
return null;
}
示例8: SubscribeWithGroupSelection_Successful
public void SubscribeWithGroupSelection_Successful()
{
// Arrange
MailChimpManager mc = new MailChimpManager(TestGlobal.Test_APIKey);
ListResult lists = mc.GetLists();
EmailParameter email = new EmailParameter()
{
Email = "[email protected]"
};
// find a list with interest groups...
string strListID = null;
int nGroupingID = 0;
string strGroupName = null;
foreach (ListInfo li in lists.Data) {
List<InterestGrouping> interests = mc.GetListInterestGroupings(li.Id);
if (interests != null) {
if (interests.Count > 0) {
if (interests[0].GroupNames.Count > 0) {
strListID = li.Id;
nGroupingID = interests[0].Id;
strGroupName = interests[0].GroupNames[0].Name;
break;
}
}
}
}
Assert.IsNotNull(strListID,"no lists found in this account with groupings / group names");
Assert.AreNotEqual(0,nGroupingID);
Assert.IsNotNull(strGroupName);
MyMergeVar mvso = new MyMergeVar();
mvso.Groupings = new List<Grouping>();
mvso.Groupings.Add(new Grouping());
mvso.Groupings[0].Id = nGroupingID;
mvso.Groupings[0].GroupNames = new List<string>();
mvso.Groupings[0].GroupNames.Add(strGroupName);
mvso.FirstName = "Testy";
mvso.LastName = "Testerson";
// Act
EmailParameter results = mc.Subscribe(strListID, email, mvso);
// Assert
Assert.IsNotNull(results);
Assert.IsTrue(!string.IsNullOrEmpty(results.LEId));
}
示例9: RegisterHouseholdMembers
public ActionResult RegisterHouseholdMembers(HouseholdMemberModel householdMemberModel)
{
AddressModel address = new UserService().GetAddressById(householdMemberModel.AddressId);
//Don't allow duplicate user
var tryToFindUser = Membership.GetUserNameByEmail(householdMemberModel.Email);
if (string.IsNullOrEmpty(tryToFindUser))
{
var id = Guid.NewGuid();
Boolean isFBUser = false;
Boolean isApproved = true;
Int32 FBUserId = 0;
// create the ASP membership user
MembershipCreateStatus status;
var membershipUser = Membership.CreateUser(username: householdMemberModel.Email, password: householdMemberModel.Password, email: householdMemberModel.Email,
passwordQuestion: null, passwordAnswer: null,
isApproved: isApproved, providerUserKey: id,
status: out status
);
// Check inviter user role and the same role for invited user
var addressHolderUserEmail = new UserService().GetUserNameHolderForAddress(householdMemberModel.AddressId);
if (!string.IsNullOrWhiteSpace(addressHolderUserEmail))
{
if (Roles.IsUserInRole(addressHolderUserEmail, "Supplier") && membershipUser != null)
{
Roles.AddUserToRole(membershipUser.Email, "Supplier");
}
}
if (status == MembershipCreateStatus.Success)
{
// create the GM user
var user = new UserModel
{
Id = id,
FirstName = householdMemberModel.FirstName,
LastName = householdMemberModel.LastName,
AddressModel = address,
AddressId = address.Id,
Instance_Id = address.Instance_Id,
SendEmailOffers = householdMemberModel.SendEmailOffers,
SendEmailUpdates = householdMemberModel.SendEmailUpdates,
IsFBAccount = isFBUser,
FBUserId = FBUserId,
IsAdditionalAccountHolder = true
};
// Give them the New Member Bonus
int numBonusPoints = Convert.ToInt16(ConfigurationManager.AppSettings["BonusPoints.NewMember.Points"]);
string descBonusPoints = Convert.ToString(ConfigurationManager.AppSettings["BonusPoints.NewMember.Description"]);
int? transactionTypeId = Convert.ToInt16(ConfigurationManager.AppSettings["TransactionType.ShareHeart"]);
// store it
var newUser = new UserService().CreateUser(user, numBonusPoints, descBonusPoints, transactionTypeId);
int numBonusInvitationAcceptedPoints = Convert.ToInt16(ConfigurationManager.AppSettings["BonusPoints.InviteMember.Points"]);
string descInvitationAcceptedBonusPoints = Convert.ToString(ConfigurationManager.AppSettings["BonusPoints.InviteMember.Description"]);
bool addPoints = new UserService().InvitationAcceptedAddBonusPoints(addressHolderUserEmail,
numBonusInvitationAcceptedPoints, descInvitationAcceptedBonusPoints, transactionTypeId);
SendVerifyEmail(membershipUser.Email, user.FirstName, user.Id, true);
bool isProduction = Convert.ToBoolean(ConfigurationManager.AppSettings["MailChimp.ListId"]);
if (isProduction)
{
// Add them to the relevant MailChimp List
MailChimpManager mc = new MailChimpManager(ConfigurationManager.AppSettings["MailChimp.APIKey"]);
EmailParameter email = new EmailParameter()
{
Email = user.Email
};
EmailParameter results = mc.Subscribe(ConfigurationManager.AppSettings["MailChimp.ListId"], email);
}
return RedirectToAction("RegisterAccountSuccess");
}
else
{
ModelState.AddModelError("", ErrorCodeToString(status));
return View(householdMemberModel);
}
}
else
{
// email has already been registered in the system
ModelState.AddModelError("", "User with the same email address has already been registered with GreenMoney.");
return View(householdMemberModel);
}
}
示例10: SubscribeWithGroupSelectionUsingDictonary_Successful
public void SubscribeWithGroupSelectionUsingDictonary_Successful() {
// Arrange
MailChimpManager mc = new MailChimpManager(TestGlobal.Test_APIKey);
ListResult lists = mc.GetLists();
EmailParameter email = new EmailParameter() {
Email = "[email protected]"
};
// find a list with interest groups...
string strListID = null;
int nGroupingID = 0;
string strGroupName = null;
foreach (ListInfo li in lists.Data) {
List<InterestGrouping> interests = mc.GetListInterestGroupings(li.Id);
if (interests != null) {
if (interests.Count > 0) {
if (interests[0].GroupNames.Count > 0) {
strListID = li.Id;
nGroupingID = interests[0].Id;
strGroupName = interests[0].GroupNames[0].Name;
break;
}
}
}
}
Assert.IsNotNull(strListID, "no lists found in this account with groupings / group names");
Assert.AreNotEqual(0, nGroupingID);
Assert.IsNotNull(strGroupName);
MergeVar mvso = new MergeVar();
mvso.Groupings = new List<Grouping>();
mvso.Groupings.Add(new Grouping());
mvso.Groupings[0].Id = nGroupingID;
mvso.Groupings[0].GroupNames = new List<string>();
mvso.Groupings[0].GroupNames.Add(strGroupName);
mvso.Add("FNAME","Testy" + DateTime.Now);
mvso.Add("LNAME", "Testerson" + DateTime.Now);
// Act
EmailParameter results = mc.Subscribe(strListID, email, mvso);
// Assert
Assert.IsNotNull(results);
Assert.IsTrue(!string.IsNullOrEmpty(results.LEId));
// load
List<EmailParameter> emails = new List<EmailParameter>();
emails.Add(results);
MemberInfoResult memberInfos = mc.GetMemberInfo(strListID, emails);
// Assert
Assert.AreEqual(1, memberInfos.SuccessCount);
Assert.AreEqual(2, memberInfos.Data[0].MemberMergeInfo.Count);
Assert.AreEqual(mvso["FNAME"], memberInfos.Data[0].MemberMergeInfo["FNAME"]);
Assert.AreEqual(mvso["LNAME"], memberInfos.Data[0].MemberMergeInfo["LNAME"]);
}
示例11: UpdateMember_Successful
public void UpdateMember_Successful()
{
// Arrange
MailChimpManager mc = new MailChimpManager(TestGlobal.Test_APIKey);
ListResult lists = mc.GetLists();
EmailParameter email = new EmailParameter()
{
Email = "[email protected]"
};
var listId = lists.Data[0].Id;
MyMergeVar mergeVar = new MyMergeVar();
EmailParameter subscriptionResults = mc.Subscribe(listId, email, mergeVar, "html", false, true);
// Act
mergeVar.FirstName = "some name";
mc.UpdateMember(listId, subscriptionResults, mergeVar);
// load
List<EmailParameter> emails = new List<EmailParameter>();
emails.Add(email);
MemberInfoResult memberInfos = mc.GetMemberInfo(listId, emails);
// Assert
Assert.IsTrue(memberInfos.Data[0].MemberMergeInfo.ContainsKey("FNAME"));
Assert.AreEqual("some name", memberInfos.Data[0].MemberMergeInfo["FNAME"]);
}