PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, September 6, 2022

[FIXED] how to create tags in the lists of mailchimp subscriber using nodejs?

 September 06, 2022     mailchimp-api-v3.0, node.js     No comments   

Issue

I had created the mail subscription using mailchimp. The mail id is listed in the lists of mailchimp, but i want to pass the firstname,lastname and want to create a tag while doing the mailchimp subscription. but now i am listing only the mail under my list.. when i am trying to create the tag via postman, the tags are created, but i want to add through api code.

var mailchimpInstance   = '***',
    listUniqueId        = '*********',
    mailchimpApiKey     = '*****************';

app.post('/signup', function (req, res) {
    request
        .post('https://' + mailchimpInstance + '.api.mailchimp.com/3.0/lists/' + listUniqueId + '/members/')
        .set('Content-Type', 'application/json;charset=utf-8')
        .set('Authorization', 'Basic ' + new Buffer('any:' + mailchimpApiKey ).toString('base64'))
        .send({
          'email_address': req.body.email,
          'status': 'subscribed',
          'merge_fields': {
            "FNAME": req.body.fname,
            "LNAME": req.body.lname
            }
        })
        .end(function(err, response) {
         if (response.status < 300 || (response.status === 400 && response.body.title === "Member Exists")) {
          res.send('Sign Up Success :)');
          } else {
                res.send('Sign Up Failed :(');
              }
              console.log(req.body.email);
          });

    });

This code is for sending the email to the lists..in this code the firstname and lastname is not listed in the lists of mailchimp..and i also need to create tags using this api


Solution

There's a 'tags' body parameter which accepts an array and adds the tags to the mail id. Here's the documentation: https://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#%20



Answered By - Pancasm
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing