Advertisement
aa_frey

mailchimp python

Mar 30th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. chimp = mailchimp.Mailchimp('my api key')
  2. LIST_ID = 'my list id'
  3.  
  4. @app.route('/webhook', methods=['POST'])
  5. def webhook():
  6. req = request.get_json(silent=True, force=True)
  7. print("Request:")
  8. print req['result']['action']
  9.  
  10. email = req['result']['parameters']['email']
  11. fname = req['result']['parameters']['fname']
  12. print email + ' ' + fname
  13.  
  14. if req.get("result", {}).get("action", {}) != "list_management":
  15. return {}
  16. else:
  17. print 'else statement ran'
  18. chimp.lists.subscribe(LIST_ID,
  19. {'email': email},
  20. merge_vars={'FNAME': fname},
  21. send_welcome=False)
  22. print 'success'
  23. print 'else statement over'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement