【问题标题】:Mailchimp createCampaign exception 506Mailchimp createCampaign 异常 506
【发布时间】:2011-08-20 19:31:24
【问题描述】:

我正在尝试使用 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=必须包含“选项”参数并且必须是数组/散列。

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

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

【问题讨论】:

  • $content 中的 'html' 应该是原始 HTML 代码,而不是链接

标签: php email hash mailchimp


【解决方案1】:

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

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

应该是:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-22
    • 1970-01-01
    • 2017-07-07
    • 1970-01-01
    • 2021-09-20
    • 2016-09-11
    • 2021-12-05
    相关资源
    最近更新 更多