Created
February 4, 2016 16:33
-
-
Save dimmg/58741c99988e9ea6f99e to your computer and use it in GitHub Desktop.
mailchimp v3.0 with python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import requests | |
# mailchimp api_key and list_id | |
MAILCHIMP_API_KEY = 'da29dawdn2138dwdawdn21k38-us10' | |
MAILCHIMP_LIST_ID = 'dfi2ndwa2' | |
us_ = MAILCHIMP_API_KEY.split('-')[1] | |
mailchimp_api_root = "https://" + us_ + ".api.mailchimp.com/3.0/" | |
endpoint = mailchimp_api_root + "lists/" + MAILCHIMP_LIST_ID + "/members/" | |
# subscribing user to a list | |
payload = json.dumps({"email_address": "[email protected]", "status": "subscribed"}) | |
response = requests.post(endpoint, auth=('apikey', MAILCHIMP_API_KEY), data=payload) | |
# retrieving all users from a list | |
response = requests.get(endpoint, auth=('apikey', MAILCHIMP_API_KEY)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment