本文整理匯總了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 ***"