当前位置: 首页>>代码示例>>Python>>正文


Python PostMonkey.listSubscribe方法代码示例

本文整理汇总了Python中postmonkey.PostMonkey.listSubscribe方法的典型用法代码示例。如果您正苦于以下问题:Python PostMonkey.listSubscribe方法的具体用法?Python PostMonkey.listSubscribe怎么用?Python PostMonkey.listSubscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在postmonkey.PostMonkey的用法示例。


在下文中一共展示了PostMonkey.listSubscribe方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handleApply

# 需要导入模块: from postmonkey import PostMonkey [as 别名]
# 或者: from postmonkey.PostMonkey import listSubscribe [as 别名]
 def handleApply(self, action):
     data, errors = self.extractData()
     if 'email' in data:
         # Fetch MailChimp settings
         registry = getUtility(IRegistry)
         mailchimp_settings = registry.forInterface(IMailchimpSettings)
         if len(mailchimp_settings.api_key) == 0:
             return
         mailchimp = PostMonkey(mailchimp_settings.api_key)
         # Fetch MailChimp lists
         # XXX, Todo: For now we just fetch the first list.
         try:
             lists = mailchimp.lists()['data']
             list_id = lists[0]['id']
         except MailChimpException, error:
             raise WidgetActionExecutionError(
                 Invalid(_(u"Could not fetch list from mailchimp.com: %s" %
                     error)))
         # Subscribe to MailChimp list
         try:
             mailchimp.listSubscribe(
                 id=list_id,
                 email_address=data['email'])
         except MailChimpException, error:
             raise WidgetActionExecutionError(
                 'email',
                 Invalid(_(
                     u"Could not subscribe to newsletter: %s" % error)))
开发者ID:fourdigits,项目名称:collective.mailchimp,代码行数:30,代码来源:newsletter.py

示例2: SignupWorker

# 需要导入模块: from postmonkey import PostMonkey [as 别名]
# 或者: from postmonkey.PostMonkey import listSubscribe [as 别名]
class SignupWorker(QueueProcessingWorker):
    def __init__(self):
        super(SignupWorker, self).__init__()
        if settings.MAILCHIMP_API_KEY:
            self.pm = PostMonkey(settings.MAILCHIMP_API_KEY, timeout=10)

    def consume(self, data):
        merge_vars=data['merge_vars']
        # This should clear out any invitation reminder emails
        clear_followup_emails_queue(data["EMAIL"])
        if settings.MAILCHIMP_API_KEY and settings.PRODUCTION:
            try:
                self.pm.listSubscribe(
                        id=settings.ZULIP_FRIENDS_LIST_ID,
                        email_address=data['EMAIL'],
                        merge_vars=merge_vars,
                        double_optin=False,
                        send_welcome=False)
            except MailChimpException as e:
                if e.code == 214:
                    logging.warning("Attempted to sign up already existing email to list: %s" % (data['EMAIL'],))
                else:
                    raise e

        email = data.get("EMAIL")
        name = merge_vars.get("NAME")
        enqueue_welcome_emails(email, name)
开发者ID:150vb,项目名称:zulip,代码行数:29,代码来源:queue_processors.py

示例3: register

# 需要导入模块: from postmonkey import PostMonkey [as 别名]
# 或者: from postmonkey.PostMonkey import listSubscribe [as 别名]
def register():
    statsd.increment('api_calls.register')
    form = SignupForm(request.form)
    logger.info(request.form)
    if not form.validate():
        msg = {
            'success': False,
            'msg': form.errors}
        return jsonify(msg)
    user = session.query(Person).\
        filter(Person.email == form.email.data
               ).first()
    if user:
        msg = {
            'success': False,
            'msg': user.email + ' is already registered!',
            'parameter': 'email', }
        return jsonify(msg)
    u = Person(form)
    session.add(u)
    session.commit()
    try:
        pm = PostMonkey(apikey=MC_APIKEY, timeout=10)
        pm.listSubscribe(
            id=MC_LISTID, email_address=form.email.data)
    except MailChimpException, e:
        app.logger.error(str(e))
开发者ID:dhilipsiva,项目名称:moback,代码行数:29,代码来源:api.py

示例4: email_chimp

# 需要导入模块: from postmonkey import PostMonkey [as 别名]
# 或者: from postmonkey.PostMonkey import listSubscribe [as 别名]
def email_chimp(request):
	email = request.POST['email']
	apikey = 'a36024c7bb5504d63b61963dd9741fa2-us8'
	mailid = 'c4ed436de6'

	pm = PostMonkey(apikey)
	pm.listSubscribe(id = mailid, email_address = email, double_optin = False)
	return HttpResponse()
开发者ID:AndreaLugli,项目名称:InstAutomation,代码行数:10,代码来源:views.py

示例5: gumroad

# 需要导入模块: from postmonkey import PostMonkey [as 别名]
# 或者: from postmonkey.PostMonkey import listSubscribe [as 别名]
def gumroad():
	# We have passed the shared secret or we didn't care about it
	pm = PostMonkey(os.environ.get('MAILCHIMP_API_KEY',''))

	# Get a posted email address
	email = request.form.get('email',None)
	if not email == None:
		# Send that off to Mailchimp
		pm = PostMonkey(os.environ.get('MAILCHIMP_API_KEY',''))
		try:
			pm.listSubscribe(id=os.environ.get('MAILCHIMP_LIST_ID',''),email_address=email,double_optin=False)
		except MailChimpException, e:
			print e.code  # 200
			print e.error # u'Invalid MailChimp List ID: 42'
			return file('templates/401.json').read(), 401
开发者ID:optional-is,项目名称:email2mailchimp,代码行数:17,代码来源:run.py

示例6: subscribe

# 需要导入模块: from postmonkey import PostMonkey [as 别名]
# 或者: from postmonkey.PostMonkey import listSubscribe [as 别名]
def subscribe():
    # We have passed the shared secret or we didn't care about it
    pm = PostMonkey(MAILCHIMP_API_KEY)
    
    # Get a posted email address
    email = request.form.get('email',None)
    if not email == None:
        # Send that off to Mailchimp
        pm = PostMonkey(MAILCHIMP_API_KEY)
        try:
            pm.listSubscribe(id=MAILCHIMP_LIST_ID, email_address=email,double_optin=False)
        except MailChimpException, e:
            print e.code  # 200
            print e.error # u'Invalid MailChimp List ID: 42'
            flash('Error: ' + str(e.error))
            return redirect(url_for('homepage'))
开发者ID:spanners,项目名称:flask-stripe-registration,代码行数:18,代码来源:views.py

示例7: salva_email

# 需要导入模块: from postmonkey import PostMonkey [as 别名]
# 或者: from postmonkey.PostMonkey import listSubscribe [as 别名]
def salva_email(request):
	instance = UserSocialAuth.objects.get(user=request.user, provider='instagram')

	email = request.POST['email']

	try:
		apikey = 'a36024c7bb5504d63b61963dd9741fa2-us8'
		mailid = 'c4ed436de6'

		pm = PostMonkey(apikey)
		pm.listSubscribe(id = mailid, email_address = email, double_optin = False)
	except:
		pass

	Utente.objects.filter(utente = instance).update(email = email)
	return HttpResponse()
开发者ID:AndreaLugli,项目名称:InstAutomation,代码行数:18,代码来源:views.py

示例8: subscribe

# 需要导入模块: from postmonkey import PostMonkey [as 别名]
# 或者: from postmonkey.PostMonkey import listSubscribe [as 别名]
def subscribe():
	if os.environ.get('SECRET_KEY',None) != None or request.form.get('sk',None) != None:
		secret_key = os.environ.get('SECRET_KEY',None)
		if secret_key != request.form.get('sk',None):
			# We were expecting a secret key because one is set, but we didn't or it didn't match
			return file('templates/401.json').read(), 401
		
	# We have passed the shared secret or we didn't care about it
	pm = PostMonkey(os.environ.get('MAILCHIMP_API_KEY',''))
	
	# Get a posted email address
	email = request.form.get('email',None)
	if not email == None:
		# Send that off to Mailchimp
		pm = PostMonkey(os.environ.get('MAILCHIMP_API_KEY',''))
		try:
			pm.listSubscribe(id=os.environ.get('MAILCHIMP_LIST_ID',''),email_address=email,double_optin=False)
		except MailChimpException, e:
			print e.code  # 200
			print e.error # u'Invalid MailChimp List ID: 42'
			return file('templates/401.json').read(), 401
开发者ID:optional-is,项目名称:email2mailchimp,代码行数:23,代码来源:run.py

示例9: strip2mailchimp

# 需要导入模块: from postmonkey import PostMonkey [as 别名]
# 或者: from postmonkey.PostMonkey import listSubscribe [as 别名]
def strip2mailchimp():
	"""
	{
	  "created": 1326853478,
	  "livemode": false,
	  "id": "evt_00000000000000",
	  "type": "charge.succeeded",
	  "object": "event",
	  "request": null,
	  "data": {
	    "object": {
	      "id": "ch_00000000000000",
	      "object": "charge",
	      "created": 1412117456,
	      "livemode": false,
	      "paid": true,
	      "amount": 100,
	      "currency": "eur",
	      "refunded": false,
	      "card": {
	        "id": "card_00000000000000",
	        "object": "card",
	        "last4": "4242",
	        "brand": "Visa",
	        "funding": "credit",
	        "exp_month": 8,
	        "exp_year": 2015,
	        "fingerprint": "3WqOgApKDjCTvHEG",
	        "country": "US",
	        "name": null,
	        "address_line1": null,
	        "address_line2": null,
	        "address_city": null,
	        "address_state": null,
	        "address_zip": null,
	        "address_country": null,
	        "cvc_check": "pass",
	        "address_line1_check": null,
	        "address_zip_check": null,
	        "customer": null
	      },
	      "captured": true,
	      "refunds": {
	        "object": "list",
	        "total_count": 0,
	        "has_more": false,
	        "url": "/v1/charges/ch_14iZSOLQaIfBBJAWXuK7DE0I/refunds",
	        "data": []
	      },
	      "balance_transaction": "txn_00000000000000",
	      "failure_message": null,
	      "failure_code": null,
	      "amount_refunded": 0,
	      "customer": null,
	      "invoice": null,
	      "description": "My First Test Charge (created for API docs)",
	      "dispute": null,
	      "metadata": {},
	      "statement_description": null,
	      "receipt_email": null,
	      "receipt_number": null
	    }
	  }
	}
	"""

	# locally use .form
	#i = request.form
	#for k in i:
	#	event_json = json.loads(k)
		
	event_json = json.loads(request.data)

	# we have the data we are looking for
	if 'type' in event_json and event_json['type'] == 'charge.succeeded':
		# Get the email address
		email = event_json['data']['object']['receipt_email']
		
		if not email == None:
			# Send that off to Mailchimp
			pm = PostMonkey(os.environ.get('MAILCHIMP_API_KEY',''))
			try:
				pm.listSubscribe(id=os.environ.get('MAILCHIMP_LIST_ID',''),email_address=email,double_optin=False)
			except MailChimpException, e:
				print e.code  # 200
				print e.error # u'Invalid MailChimp List ID: 42'
				return file('templates/500.json').read(), 500
开发者ID:optional-is,项目名称:email2mailchimp,代码行数:89,代码来源:run.py


注:本文中的postmonkey.PostMonkey.listSubscribe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。