Mandrill验证错误:请输入数组

2024-09-30 01:36:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试在Google App Engine上使用Mandrill,并与Python一起使用,为此我使用了Google提供的urlfetch模块。在

我使用的代码的改编如下:

#The jMessage below was split with the formatting below to make it easier to follow#the real code doesn't have such indentation issues

jMessage =
{
"key": mailchimp_key,
"message": 
    {
    "track_clicks": False,
    "track_opens": True,
    "tags": [],
    "google_analytics_domains": [],
    "html": message_html,
    "subject": "Reset your password",
    "from_name": None,
    "merge_var_map": {},
    "auto_text": False,
    "from_email": from_email,
    "headers": {},
    "google_analytics_campaign": [],
    "merge_vars": [],
    "text": None,
    "global_merge_vars": [],
    "url_strip_qs":False,
    "to":   
            [
                {
                "email": to_email,
                "name": None
                }
            ]
    }
}

headers = {'content-type': 'application/json'}

result = urlfetch.fetch(url='https://mandrillapp.com/api/1.0/messages/send.json',\
              headers=headers, payload=json.dumps(jMessage), method=urlfetch.POST)

print result.content

其输出如下:

^{pr2}$

它想要的数组到底是什么?我不知道该怎么做,所以我用jMessage和{}包装了“message”键,使之成为一个列表。实际上,它不再抱怨数组,但是输出只是[],我也没有收到任何电子邮件。在


Tags: thetokeyfromnonejsonfalsemessage

热门问题