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'=>'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-&g开发者_开发知识库t;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.
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,
$cid = $api->campaignCreate($apikey, 'auto', $opts, $content);
Should be:
$cid = $api->campaignCreate('auto', $opts, $content);
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.
精彩评论