本文整理汇总了Python中aweber_api.AWeberAPI.get_account方法的典型用法代码示例。如果您正苦于以下问题:Python AWeberAPI.get_account方法的具体用法?Python AWeberAPI.get_account怎么用?Python AWeberAPI.get_account使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aweber_api.AWeberAPI
的用法示例。
在下文中一共展示了AWeberAPI.get_account方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WhenGettingAnAccount
# 需要导入模块: from aweber_api import AWeberAPI [as 别名]
# 或者: from aweber_api.AWeberAPI import get_account [as 别名]
class WhenGettingAnAccount(TestCase):
def setUp(self):
self.aweber = AWeberAPI(key, secret)
self.aweber.adapter = MockAdapter()
self.access_token = "1234"
self.token_secret = "abcd"
def test_when_getting_an_account(self):
account = self.aweber.get_account(self.access_token, self.token_secret)
self.assertEqual(type(account), AWeberEntry)
self.assertEqual(account.id, 1)
self.assertEqual(account.type, "account")
示例2: set_list_names
# 需要导入模块: from aweber_api import AWeberAPI [as 别名]
# 或者: from aweber_api.AWeberAPI import get_account [as 别名]
def set_list_names(widgets):
"""Writes list names to registry record.
:param widgets: object to read data from it
:type widgets: Widgets object
"""
consumer_key = widgets['consumer_key'].value
consumer_secret = widgets['consumer_secret'].value
access_token = widgets['access_token'].value
access_secret = widgets['access_secret'].value
aweber = AWeberAPI(consumer_key, consumer_secret)
account = aweber.get_account(access_token, access_secret)
api.portal.set_registry_record(
'niteoweb.aweber.available_lists_record',
[l.name for l in account.lists],
)
示例3: subscribe_to_aweber_mailinglist
# 需要导入模块: from aweber_api import AWeberAPI [as 别名]
# 或者: from aweber_api.AWeberAPI import get_account [as 别名]
def subscribe_to_aweber_mailinglist(email, fullname):
"""Subscribe a member to Aweber mailinglist.
:param email: email address of user to subscribe
:type email: string
:param fullname: full name of the user related to previous argument
:type fullname: string
"""
consumer_key = api.portal.get_registry_record(
'niteoweb.aweber.interfaces.IAweberSettings.consumer_key'
)
consumer_secret = api.portal.get_registry_record(
'niteoweb.aweber.interfaces.IAweberSettings.consumer_secret'
)
access_token = api.portal.get_registry_record(
'niteoweb.aweber.interfaces.IAweberSettings.access_token'
)
access_secret = api.portal.get_registry_record(
'niteoweb.aweber.interfaces.IAweberSettings.access_secret'
)
list_name = api.portal.get_registry_record(
'niteoweb.aweber.interfaces.IAweberSettings.list_name'
)
aweber = AWeberAPI(consumer_key, consumer_secret)
account = aweber.get_account(access_token, access_secret)
list_ = account.lists.find(name=list_name)[0]
list_url = '/accounts/%s/lists/%s' % (account.id, list_.id)
list_ = account.load_from_url(list_url)
# create a subscriber
params = {
'email': email,
'name': fullname,
}
list_.subscribers.create(**params)
示例4: AWeberInterface
# 需要导入模块: from aweber_api import AWeberAPI [as 别名]
# 或者: from aweber_api.AWeberAPI import get_account [as 别名]
class AWeberInterface(object):
def __init__(self):
# replace XXX with your keys
consumer_key = 'Ak7W3K2vE3pODdOyag0t5X79'
consumer_secret = 'ekxdnHs8aPgHIlI6RBLk3BynpylWEHCzSr4042vP'
self.access_token = 'Agv7HS28IZoTDI05Zt1LuLIt'
self.access_secret = 's2NucR72EL8S9KKmlriAhNNCP04mG1tqOsCkII5O'
self.application = AWeberAPI(consumer_key, consumer_secret)
self.account = self.application.get_account(self.access_token, self.access_secret)
print self.application
print self.account
def connect_to_AWeber_account(self):
app_id = '7XXXXXX8'
authorization_url = 'https://auth.aweber.com/1.0/oauth/authorize_app/%s' % app_id
print 'Go to this url in your browser: %s' % authorization_url
authorization_code = raw_input('Type code here: ')
auth = AWeberAPI.parse_authorization_code(authorization_code)
consumer_key, consumer_secret, access_key, access_secret = auth
print auth
return auth
def find_list(self):
lists = self.account.lists.find(name="makerspace")
return lists[0]
def find_subscriber(self):
subscribers = self.account.findSubscribers(email="[email protected]")
return subscribers[0]
def add_subscriber(self, subscriber, _list):
list_url = '/accounts/%s/lists/%s' % (self.account.id, _list.id)
print list_url
_list = self.account.load_from_url(list_url)
print _list
success = False
data = {}
try:
new_subscriber = _list.subscribers.create(**subscriber)
print new_subscriber
success = True
data = {
'email': new_subscriber.email
}
except APIException, exc:
print APIException
print exc
report = exc.message.split(':')
# WebServiceError: email: Subscriber already subscribed and has not confirmed.
data = {
'class': report[0].strip(),
'category': report[1].strip(),
'status': report[2].strip()
}
except Exception, exc:
print exc
示例5: str
# 需要导入模块: from aweber_api import AWeberAPI [as 别名]
# 或者: from aweber_api.AWeberAPI import get_account [as 别名]
from aweber_api import AWeberAPI, APIException
email = str(sys.argv[1])
validation_code = str(sys.argv[2])
#Your Credentials
consumer_key = 'cred'
consumer_secret = 'en'
access_key = 'ti'
access_secret = 'als'
#list_id of the list you want to subscribe the user
list_id = 'yourlistid'
aweber = AWeberAPI(consumer_key, consumer_secret)
try:
account = aweber.get_account(access_key, access_secret)
list_url = '/accounts/%s/lists/%s' % (account.id, list_id)
list_ = account.load_from_url(list_url)
# create a subscriber
params = {
'email': email,
'ad_tracking': validation_code,
}
subscribers = list_.subscribers
new_subscriber = subscribers.create(**params)
except APIException, exc:
print exc