2015-10-13 23 views
1

创建mailchimp API V2运动我有我我需要更新一些API 1.3过时的页面,但我在努力寻找2.0版使用drewm包装

许多工作PHP的例子我已经找到了drewm wrapper,我有必须为列表订阅等工作,但我在创建广告系列时遇到问题。

下面的代码片段,我相信符合预期的输入,但是当我运行它,我得到的消息无效MailChimp列表ID,虽然我知道这是正确的

<?php 

$options[] = array(
     'list_id' => 'list id', 
     'subject' => 'Test Campaign '.date('m/d/y g:ia'), 
     'from_email' => '[email protected]', 
     'from_name' => 'Test Sender', 
     'to_name' => 'Test Recipient', 
     'template_id' => '123456', 
     'title' => 'example title' 
    ); 

$content[] = array(
     'text' => 'example text' 
    ); 

$MailChimp = new \Drewm\MailChimp('api key'); 
$result = $MailChimp->call("campaigns/create", array(
            'type' => 'regular', 
            'options' => $options, 
            'content' => $content 
          ) 
         ); 
    var_dump($result); 

?> 

回答

0

...这是方括号建立PHP变量

这里是一个工作片段时,我曾误加...

<?php 

$options = array(
    'list_id' => 'list id', 
    'subject' => 'Test Campaign '.date('m/d/y g:ia'), 
    'from_email' => '[email protected]', 
    'from_name' => 'Test Sender', 
    'to_name' => 'Test Recipient', 
    'template_id' => '123456', 
    'title' => 'example title' 
); 

$content = array(
    'text' => 'example text' 
); 

$MailChimp = new \Drewm\MailChimp('api key'); 
$result = $MailChimp->call("campaigns/create", array(
           'type' => 'regular', 
           'options' => $options, 
           'content' => $content 
         ) 
        ); 
var_dump($result); 

?>