1

我正在尝试使用 api 和 campaignCreate() 方法创建一个 mailchimp 活动。我的代码如下:

<?php
$message = array(
  'html'=>'Yo, this is the <b>html</b> portion',
  'text'=>'Yo, this is the *text* portion',
  'subject'=>'Hey you',
  'from_name'=>'Me!',
  'from_email'=>'wedding@email.com',
'to_email'=>'starsinmypockets@email.com',
'to_name'=>'Paul',
);

$apikey = '9xxxxxxxx84f6168a82bf10c-us2';
$api = new MCAPI($apikey);
$opts['list_id'] = '0184c0c626';
$opts['subject'] = 'Testing';
$opts['from_email'] = 'wedding@email.com';
$opts['from_name'] = 'Pam & Kelly';
$opts['to_name'] = 'Dearly beloved';
$content = array(
  'html' => 'http://wedding.com/foo/bar',
  'text' => "Hey, you've been invited to Pam & Kelly's wedding. Follow the link below     to rsvp! We hope you can make it. We're going to eat ice cream and cupcakes!",
  'url' => '',
  'archive' => '',
);
$cid = $api->campaignCreate($apikey, 'auto', $opts, $content);

if ($api->errorCode){
$output = "Unable to Create New Campaign!";
$output .= "\n\tCode=".$api->errorCode;
$output .= "\n\tMsg=".$api->errorMessage."\n";
} else {
$output =  "New Campaign ID:" . $cid . "\n";
}
//$return = campaignSendNow($apikey, $cid);
return $output;

}
?>

这将返回以下错误消息:

无法创建新广告系列!Code=506 Msg=必须包含“options”参数并且必须是数组/散列。

好吧,$opts 是选项数组。它当然是一个数组,尽管我不知道“哈希”的正确含义是什么,或者这与我是否相关。

有什么想法吗?我难住了。

4

1 回答 1

1

您错误地修改了示例代码。MCAPI 包装器让您使用 构造它,$apikey因为每个方法都需要它,然后将它包含在每个调用中以简化事情。所以,

$cid = $api->campaignCreate($apikey, 'auto', $opts, $content);

应该:

$cid = $api->campaignCreate('auto', $opts, $content);

另外,从看到那里的代码混合(MCAPI 和 STS 参数变量),你的另一个问题,以及你现在正在尝试创建一个自动回复并认为你可以发送它的事实,我建议花一些在交叉引用 API 文档和知识库并在应用程序中工作时,花时间阅读有关活动类型以及事情通常如何 运作的信息。API Google Group中也有很多讨论可供查看。是的,我也在那边。

于 2011-05-07T19:01:22.457 回答