Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Small package to help your customers subscribe/update their MailChimp subscriptions.

License

NotificationsYou must be signed in to change notification settings

skybrud/Skybrud.Umbraco.MailChimp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Small NuGet package to help your customers subscribe/update their MailChimp subscriptions.

Setup C#

First of all, you need to install the NuGet Package viaInstall-Package Skybrud.Umbraco.MailChimp.

After that, you need to create at least 2 models and a controller.

Models

If you have created or altered the default MailChimp merge-fields, you need to tell Skybrud.Umbraco.MailChimp what you have done.

usingMailChimp.Lists;namespaceCustomer.Models.Website.MailChimp{publicclassCustomMailChimpMergeModel:MergeVar{publicstringNAME{get;set;}}}

You also need to tell Skybrud.Umbraco.MailChimp what properties your submit form will send. Please remember to enherit fromMailChimpSignup as shown below.

usingSystem.Net.Http;usingSkybrud.Umbraco.MailChimp.Models;namespaceCustomer.Models.Website.MailChimp{publicclassCustomMailChimpFormModel:MailChimpSignup{        #region Properties        #endregion        #region StaticspublicstaticCustomMailChimpFormModelGetModel(HttpRequestMessagerequest){returnSkyMailChimpHelper.ConvertToMailChimpSignupModel<CustomMailChimpFormModel>(request);}        #endregion}}

The deafult class you enherit from contains these properties:

#region Properties[JsonProperty("name")]publicstringName{get;set;}[JsonProperty("email")]publicstringEmail{get;set;}[JsonProperty("listid")]publicstringListId{get;set;}[JsonProperty("listname")]publicstringListName{get;set;}[JsonProperty("contextid")]publicstringContextId{get;set;}[JsonProperty("existingUser")]publicboolExistingUser{get;set;}[JsonProperty("groups")]publicList<SkyMailChimpGroup>Groups{get;set;}[JsonProperty("config")]publicMailChimpOptionsConfig{get;set;}#endregion

Controller

You also need to create a controller to handle your api-call from the frontend. Here you can find an example:

usingSystem;usingSystem.Net;usingSystem.Net.Http;usingSystem.Web;usingSystem.Web.Http;usingMailChimp.Helper;usingServiceStack.Text;usingSkybrud.Umbraco.MailChimp.Models;usingUmbraco.Core.Logging;usingUmbraco.Web.WebApi;usingCustomer.Models.Website.MailChimp;namespaceCustomer.Controllers.Api.MailChimp{publicclassMailChimpSignupController:UmbracoApiController{[HttpPost]publicobjectSaveUpdate(HttpRequestMessagerequest){try{// cast your custom mailchimp form modelCustomMailChimpFormModelmco=CustomMailChimpFormModel.GetModel(request);// add your config model to the MailChimpFormModelvarconfig=newMailChimpOptions(true,"html",newCustomMailChimpMergeModel{NAME=mco.Name});mco.AddConfig(config);EmailParameterr=mco.SaveUpdateSubscriber(mco);returnRequest.CreateResponse(r);}catch(Exceptionex){LogHelper.Error<MailChimpSignupController>("mailchimp error",ex);returnRequest.CreateErrorResponse(HttpStatusCode.InternalServerError,ex.Message);}}}}

Now you can post to this api, and Skybrud.Umbraco.MailChimp will save or update your subscriber.

Umbraco Properties

skyMailChimpApiKey - API key from MailChimp (overwrites appsettingmailchimpapi in web.config)

skyMailChimpUpdateFromEmail - Overwrites default from-mailaddress for update profile e-mail

skyMailChimpUpdateFromDisplayName - Overwrites default displayname for update profile e-mail

skyMailChimpUpdateMailSubject - Overwrites default subject for update profile e-mail

skyMailChimpUpdateMailBody - Overwrites default body for update profile e-mail ({updateLink})

MailChimp template

If you want your subscribers to be able to ex. update their groups or name, you can add an update link in your MailChimp template.

<a href="https://customerdomain.com/news/newslettersignup/?email=*|EMAIL|*&amp;id=*|EMAIL_UID|*" mc:edit="std_update">Update your profile</a>

Remember to change domain + url, but leave the querystring.

Updates

0.5.3

  • Security added. You know need to have emailId from MailChimp to edit/update existing subscriber
  • Now you can send the subscriber a update-link

0.5.6

  • Added option for overwrite default from e-mail and display name (update mail)

About

Small package to help your customers subscribe/update their MailChimp subscriptions.

Topics

Resources

License

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp