Mailchimp API 'marketing_permissions' 字段总是无法通过 "This value should be of type array" 验证
Mailchimp API 'marketing_permissions' field always fails validation with "This value should be of type array"
使用 DrewM Mailchimp API PHP wrapper 我正在尝试 POST 订阅者并同时为 marketing_permissions
字段声明一个值,但是 Mailchimp API 响应坚持认为我为 marketing_permissions
字段提供的值不是数组。
但它肯定是一个数组,如下所示:
$params = [
'email_address' => $email,
'status' => 'subscribed',
'merge_fields' => [
'STATUS' => $status,
'FNAME' => $first_name,
'LNAME' => $last_name,
'JOBTITLE' => $title,
'COMPANY' => $company,
'PHONE' => $phone,
'AGENCY' => $agency,
'MESSAGE' => $message
],
'marketing_permissions' => [
[
'marketing_permission_id' => '1234567890',
'enabled' => true
]
]
];
$subscriptionResult = $MailChimp->post('lists/1234567890/members', $params);
我从 MC API 得到的回复是:
Array
(
[type] => http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/
[title] => Invalid Resource
[status] => 400
[detail] => The resource submitted could not be validated. For field-specific details, see the 'errors' array.
[errors] => Array
(
[0] => Array
(
[field] => marketing_permissions
[message] => This value should be of type array
)
)
)
有人知道为什么 MC API 不接受我的数组作为数组吗?
它应该是这样的
marketing_permissions: [
{
'marketing_permission_id': '123123',
'enabled': true
}
]
有兴趣得到你的 marketing_permission_id 你需要通过 API 订阅列表并检查响应,会有这个唯一的 id
使用 DrewM Mailchimp API PHP wrapper 我正在尝试 POST 订阅者并同时为 marketing_permissions
字段声明一个值,但是 Mailchimp API 响应坚持认为我为 marketing_permissions
字段提供的值不是数组。
但它肯定是一个数组,如下所示:
$params = [
'email_address' => $email,
'status' => 'subscribed',
'merge_fields' => [
'STATUS' => $status,
'FNAME' => $first_name,
'LNAME' => $last_name,
'JOBTITLE' => $title,
'COMPANY' => $company,
'PHONE' => $phone,
'AGENCY' => $agency,
'MESSAGE' => $message
],
'marketing_permissions' => [
[
'marketing_permission_id' => '1234567890',
'enabled' => true
]
]
];
$subscriptionResult = $MailChimp->post('lists/1234567890/members', $params);
我从 MC API 得到的回复是:
Array
(
[type] => http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/
[title] => Invalid Resource
[status] => 400
[detail] => The resource submitted could not be validated. For field-specific details, see the 'errors' array.
[errors] => Array
(
[0] => Array
(
[field] => marketing_permissions
[message] => This value should be of type array
)
)
)
有人知道为什么 MC API 不接受我的数组作为数组吗?
它应该是这样的
marketing_permissions: [
{
'marketing_permission_id': '123123',
'enabled': true
}
]
有兴趣得到你的 marketing_permission_id 你需要通过 API 订阅列表并检查响应,会有这个唯一的 id