1
我試圖使用API和campaignCreate()方法創建一個mailchimp活動..我的代碼如下:Mailchimp createCampaign例外506
<?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;
}
?>
這將返回以下錯誤消息:
無法創建新的廣告系列!代碼= 506 Msg =必須包含「選項」參數,並且必須是數組/散列。
那麼,$ opts是選項數組。這當然是一個數組,但我不知道它們通過「哈希」正確地表示什麼,或者這與我有關。
有什麼想法?我很難過。
他們的文檔說什麼? – 2011-05-07 16:32:25
$ content中的'html'應該是原始HTML代碼,而不是鏈接 – 2011-06-20 04:32:14