我正在尝试使用 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 是选项数组。它当然是一个数组,尽管我不知道“哈希”的正确含义是什么,或者这与我是否相关。
有什么想法吗?我难住了。