Usage>>> from campaignmonitorapi import CampaignMonitorApi
>>> cm = CampaignMonitorApi("YOUR API KEY", None)
>>> listid = 12345
>>> email = "nowhere@gmail.com"
>>> name = "Grant"
>>> cm.add(listid, email, name)
TrueExceptionsA CampaignMonitorApi.CampaignMonitorApiException is thrown if Campaign Monitor returns an exception. "OK" return codes are ignored. The returned code is currently not included in the exception - the message is passed to the exception. TipsOne gotcha to keep in mind - when you "add", the email address goes into the standard verification loops at Campaign Monitor. So, if you're set to double-opt-in, you'll need to click the link in the resultant confirmation email before calling the get_is_subscribed() method. (It will return False until you've verified.) Another thing to note is that the add() and add_and_resubscribe() methods both support custom fields. Rather than map directly to the CM API (where the custom fields options are via separate methods), the Python API has just the two methods. If you pass custom fields, the correct CM API method will be called.
|