无法创建广告系列MailChimp API 3.0 -PHP



我正在尝试将MailChimp API 3.0与PHP集成到自定义的CMS中。当我尝试使用以下代码创建单个广告系列时,我会有一个错误消息。

代码:

$apikey = <--api-key-->;
$list_id = <--list-id-->;
use DrewMMailChimpMailChimp;
$MailChimp = new MailChimp($apikey);
$result = $MailChimp->post("campaigns", [
                'type'              => 'regular',
                'recipients'        => ['list_id'           =>  '$list_id'],
                'settings'          => ['subject_line'      =>  'test subject', 
                                        'reply_to'          =>  'test@test.com',
                                        'from_name'         =>  'test name'],
            ]);
echo "<pre>";
print_r($result);
print_r($MailChimp->getLastRequest());
echo "</pre>";

错误消息:

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.
[instance] => 
[errors] => Array
    (
        [0] => Array
            (
                [field] => 
                [message] => Schema describes object, NULL found instead
            )
    )
)

使用print_r($MailChimp->getLastRequest());

Array
(
[method] => post
[path] => campaigns
[url] => https://us8.api.mailchimp.com/3.0/campaigns
[body] => 
[timeout] => 10
[headers] => POST /3.0/campaigns HTTP/1.0
User-Agent: DrewM/MailChimp-API/3.0 (github.com/drewm/mailchimp-api)
Host: us8.api.mailchimp.com
Accept-Encoding: deflate, gzip
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Authorization: apikey <--api-key-->
Content-Length: 0
)

我已经检查了文档,搜索了,但尚未找到任何东西。如果有人有一个工作代码,可以创建一个可以开始使用的简单广告系列,我将不胜感激。我想念什么?

这是我用来完成它的代码,还要检查编码,它可能导致问题

$result = $MailChimp->post("campaigns", [
                           "type" =>"regular",
                               "recipients"=> [
                                   "list_id"=> "$list_id"
                                   ]
                               ,
                               "settings"=> [
                                   "subject_line"=> "test subject",
                                   "from_name"=> "test name",
                                   "reply_to"=> "test@test.com"
                               ]
                           ]);

最新更新