當前位置: 首頁>>代碼示例>>Python>>正文


Python PostMonkey.listBatchSubscribe方法代碼示例

本文整理匯總了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 ***"
開發者ID:t3db0t,項目名稱:EventbriteAttendeesToMailchimp,代碼行數:32,代碼來源:updateMailchimpList.py


注:本文中的postmonkey.PostMonkey.listBatchSubscribe方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。