使用drewm包装器使用mailchimp api v2创建活动

时间:2015-10-13 19:31:08

标签: php api mailchimp

我有一些api 1.3已弃用的页面,我需要更新,但我很难找到许多适用于v 2.0的php示例

我找到了drewm wrapper我必须为列表订阅等工作,但我在制作广告系列时遇到了问题。

这是一个代码片段,我相信它符合预期的输入,但是当我运行它时,我收到消息Invalid MailChimp List ID,虽然我知道它是正确的

<?php 

$options[] = array(
      'list_id' => 'list id',
      'subject' => 'Test Campaign '.date('m/d/y g:ia'),
      'from_email' => 'email@hotmail.com',
      '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);

?>

1 个答案:

答案 0 :(得分:0)

...这是我在设置php变量时错误添加的方括号

这是一个工作片段......

<?php 

$options = array(
  'list_id' => 'list id',
  'subject' => 'Test Campaign '.date('m/d/y g:ia'),
  'from_email' => 'email@hotmail.com',
  '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);

 ?>
相关问题