阿罗哈朋友们,
为这个愚蠢的问题道歉,我对 Python 和编程还处于起步阶段,我正在努力寻找一种更好的方法来完成一项非常非常手动的任务。
我想使用它的 API 从 Campaign Monitor 获取所有订阅者
我已经阅读并重新阅读了 API 文档,得出的结论是我需要使用这段代码:
from __future__ import absolute_import
import json
from createsend.createsend import CreateSendBase, BadRequest
from createsend.utils import json_to_py, validate_consent_to_track
class Subscriber(CreateSendBase):
"""Represents a subscriber and associated functionality."""
def __init__(self, auth=None, list_id=None, email_address=None):
self.list_id = list_id
self.email_address = email_address
super(Subscriber, self).__init__(auth)
def get(self, list_id=None, email_address=None, include_tracking_preference=False):
"""Gets a subscriber by list ID and email address."""
params = {
"email": email_address or self.email_address,
"includetrackingpreference": include_tracking_preference,
}
response = self._get("/subscribers/%s.json" %
(list_id or self.list_id), params=params)
return json_to_py(response)
我对代码有点迷茫,我不确定是否需要使用 API 密钥在其上方附加创建发送类,并且上面是否会给我一个完整的 Json 订阅者列表..?
我目前正在 Udemy 上学习基本的 API 课程,所以我知道如何使用邮递员并使用 Flask 运行基本的 api 调用,但我没有见过或使用过 Createsend。
代码的 Github 在这里
文档在这里
对于阅读本文的任何人,我非常感谢您的时间,(无论您是否回复)!
此致,Datanovice。