Mailchimp createCampaign 异常 506
我正在尝试使用 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'=>'[email protected]',
'to_email'=>'[email protected]',
'to_name'=>'Paul',
);
$apikey = '9xxxxxxxx84f6168a82bf10c-us2';
$api = new MCAPI($apikey);
$opts['list_id'] = '0184c0c626';
$opts['subject'] = 'Testing';
$opts['from_email'] = '[email protected]';
$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 是选项数组。它肯定是一个数组,尽管我不知道“哈希”的正确含义是什么,也不知道这是否与我相关。
有什么想法吗?我很困惑。
I'm trying to create a mailchimp campaign using the api and the campaignCreate() method.. My code i as follows:
<?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'=>'[email protected]',
'to_email'=>'[email protected]',
'to_name'=>'Paul',
);
$apikey = '9xxxxxxxx84f6168a82bf10c-us2';
$api = new MCAPI($apikey);
$opts['list_id'] = '0184c0c626';
$opts['subject'] = 'Testing';
$opts['from_email'] = '[email protected]';
$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;
}
?>
This returns the following error message:
Unable to Create New Campaign! Code=506 Msg=The "options" parameter must be included and must be an array/hash.
Well, $opts is the option array. It is certainly an array, though I don't know what they properly mean by "hash" or if this is relevant to me.
Any thoughts? I'm stumped.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您错误地修改了示例代码。 MCAPI 包装器让您使用
$apikey
构建它,因为每个方法都需要它,然后将它包含在每次调用中以简化操作。所以,应该是:
此外,从查看您那里的代码混合(MCAPI 和 STS 参数变量)来看,您的 其他问题,事实上您现在正在尝试创建一个自动回复器并认为您可以发送它,我建议花一些时间阅读有关活动类型以及如何进行的信息事物通常在交叉引用 API 文档与知识库并在应用程序中工作时工作。 API Google 论坛中也有很多讨论可供查看。是的,那边也是我。
You modified the sample code incorrectly. The MCAPI wrapper has you construct it with the
$apikey
since every method requires it and then includes it with every call to simplify things. So,Should be:
Also, from seeing the mixture of code you have there (both MCAPI and STS parameter vars), your other question, and the fact that you are now trying to create an autoresponder and think you can then send it, I'd suggest spending some time reading up about the campaign types and how things generally work while cross referencing the API docs with the knowledge base and working in the app. There are lots of discussions in the API Google Group to look through, too. Yes, that's me over there, too.