本文整理汇总了Python中postmonkey.PostMonkey.listBatchSubscribe方法的典型用法代码示例。如果您正苦于以下问题:Python PostMonkey.listBatchSubscribe方法的具体用法?Python PostMonkey.listBatchSubscribe怎么用?Python PostMonkey.listBatchSubscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类postmonkey.PostMonkey
的用法示例。
在下文中一共展示了PostMonkey.listBatchSubscribe方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: event
# 需要导入模块: from postmonkey import PostMonkey [as 别名]
# 或者: from postmonkey.PostMonkey import listBatchSubscribe [as 别名]
userEvents = eb_client.user_list_events()
#print pm.ping() # returns u"Everything's Chimpy!"
idlist = [evnt['event']['id'] for evnt in userEvents['events']]
print "Found %s event(s)" % len(idlist)
print idlist
all_emails = []
print "Getting attendee emails..."
for thisid in idlist:
try:
peeps = eb_client.event_list_attendees({'id':thisid})
except EnvironmentError as e:
print e
these_emails = [peep['attendee']['email'] for peep in peeps['attendees']]
print "%s: [%s]" % (thisid, these_emails)
all_emails.extend(these_emails)
print "Found %s email(s)" % len(all_emails)
print "Updating Mailchimp list..."
mc_list_id = pm.lists()['data'][0]['id']
# the Mailchimp API wants an array of structs
email_structs = [{'EMAIL':eml} for eml in all_emails]
results = pm.listBatchSubscribe(id=mc_list_id, batch=email_structs, update_existing=True, double_optin=False)
print results
print "*** DONE ***"