Back to Documentation Overview
campaignCreate
public static campaignCreate(string apikey, string type, array options, array content, array segment_opts, array type_opts)
Create a new draft campaign to send
- Section:
- Campaign Related
- Parameters:
apikey a valid API Key for your user account. Get by calling login() type the Campaign Type to create - one of "regular", "plaintext", "absplit", "rss", "trans", "auto" options a hash of the standard options for this campaign : string list_id the list to send this campaign to- get lists using lists() string subject the subject line for your campaign message string from_email the From: email address for your campaign message string from_name the From: name for your campaign message (not an email address) string to_email the To: name recipients will see (not email address) integer template_id optional - use this template to generate the HTML content of the campaign integer folder_id optional - automatically file the new campaign in the folder_id passed array tracking optional - set which recipient actions will be tracked, as a struct of boolean values with the following keys: "opens", "html_clicks", and "text_clicks". By default, opens and HTML clicks will be tracked. string title optional - an internal name to use for this campaign. By default, the campaign subject will be used. boolean authenticate optional - set to true to enable SenderID, DomainKeys, and DKIM authentication, defaults to false. array analytics optional - if provided, use a struct with "service type" as a key and the "service tag" as a value. For Google, this should be "google"=>"your_google_analytics_key_here". Note that only "google" is currently supported - a Google Analytics tags will be added to all links in the campaign with this string attached. Others may be added in the future boolean auto_footer optional - Whether or not we should auto-generate the footer for your content. Mostly useful for content from URLs or Imports boolean inline_css optional - Whether or not css should be automatically inlined when this campaign is sent, defaults to false. boolean generate_text optional - Whether of not to auto-generate your Text content from the HTML content. Note that this will be ignored if the Text part of the content passed is not empty, defaults to false. content the content for this campaign - use a struct with the following keys: "html" for pasted HTML content "text" for the plain-text version "url" to have us pull in content from a URL. Note, this will override any other content options - for lists with Email Format options, you'll need to turn on generate_text as well "archive" to send a Base64 encoded archive file for us to import all media from. Note, this will override any other content options - for lists with Email Format options, you'll need to turn on generate_text as well "archive_type" optional - only necessary for the "archive" option. Supported formats are: zip, tar.gz, tar.bz2, tar, tgz, tbz . If not included, we will default to zip If you chose a template instead of pasting in your HTML content, then use "html_" followed by the template sections as keys - for example, use a key of "html_MAIN" to fill in the "MAIN" section of a template. Supported template sections include: "html_HEADER", "html_MAIN", "html_SIDECOLUMN", and "html_FOOTER" segment_opts optional - if you wish to do Segmentation with this campaign this array should contain: see campaignSegmentTest(). It's suggested that you test your options against campaignSegmentTest(). Also, "trans" campaigns do not support segmentation. type_opts optional - For RSS Campaigns this, array should contain: string url the URL to pull RSS content from - it will be verified and must exist string schedule optional - one of "daily", "weekly", "monthly" - defaults to "daily" string schedule_hour optional - an hour between 0 and 24 - default to 4 (4am local time) - applies to all schedule types string schedule_weekday optional - for "weekly" only, a number specifying the day of the week to send: 0 (Sunday) - 6 (Saturday) - defaults to 1 (Monday) string schedule_monthday optional - for "monthly" only, a number specifying the day of the month to send (1 - 28) or "last" for the last day of a given month. Defaults to the 1st day of the month For A/B Split campaigns, this array should contain: string split_test The values to segment based on. Currently, one of: "subject", "from_name", "schedule". NOTE, for "schedule", you will need to call campaignSchedule() separately! string pick_winner How the winner will be picked, one of: "opens" (by the open_rate), "clicks" (by the click rate), "manual" (you pick manually) integer wait_units optional - the default time unit to wait before auto-selecting a winner - use "3600" for hours, "86400" for days. Defaults to 86400. integer wait_time optional - the number of units to wait before auto-selecting a winner - defaults to 1, so if not set, a winner will be selected after 1 Day. integer split_size optional - this is a percentage of what size the Campaign's List plus any segmentation options results in. "schedule" type forces 50%, all others default to 10% string from_name_a optional - sort of, required when split_test is "from_name" string from_name_b optional - sort of, required when split_test is "from_name" string from_email_a optional - sort of, required when split_test is "from_name" string from_email_b optional - sort of, required when split_test is "from_name" string subject_a optional - sort of, required when split_test is "subject" string subject_b optional - sort of, required when split_test is "subject" For AutoResponder campaigns, this array should contain: string offset-units one of "day", "week", "month", "year" - required string offset-time the number of units, must be a number greater than 0 - required string offset-dir either "before" or "after" string event optional - "signup" (default) to base this on double-optin signup, "date" or "annual" to base this on merge field in the list string event-datemerge optional - sort of, this is required if the event is "date" or "annual" - Returns:
- string - the ID for the created campaign
- <?php
- /**
- This Example shows how to create a basic campaign via the MCAPI class.
- **/
- require_once 'inc/MCAPI.class.php';
- require_once 'inc/config.inc.php'; //contains apikey
- $type = 'regular';
- $opts['list_id'] = 'f9ee6d8616';
- $opts['subject'] = 'Test Newsletter Subject';
- $opts['from_email'] = 'mailchimp@example.org';
- $opts['from_name'] = 'ACME, Inc.';
- $opts['authenticate'] = true;
- $opts['title'] = 'Test Newsletter Title';
- 'text' => 'text text text *|UNSUB|*'
- );
- /** OR we could use this:
- $content = array('html_main'=>'some pretty html content',
- 'html_sidecolumn' => 'this goes in a side column',
- 'html_header' => 'this gets placed in the header',
- 'html_footer' => 'the footer with an *|UNSUB|* message',
- 'text' => 'text content text content *|UNSUB|*'
- );
- $opts['template_id'] = "1";
- **/
- $retval = $api->campaignCreate($type, $opts, $content);
- if ($api->errorCode){
- } else {
- }
- <?php
- /**
- This Example shows how create a basic campaign using XML-RPC.
- Note that we are using the PEAR XML-RPC client and recommend others do as well.
- **/
- require_once 'XML/RPC2/Client.php';
- require_once 'inc/config.inc.php';
- try {
- $type = 'regular';
- $opts['list_id'] = $listId;
- $opts['subject'] = 'hello thar!';
- $opts['from_email'] = $my_email;
- $opts['from_name'] = 'My Name';
- 'text_clicks' => false);
- $opts['authenticate'] = false;
- $opts['title'] = 'My 123 Campaign';
- 'text' => 'text text text *|UNSUB|*');
- $seg['match'] = 'any';
- $result = $client->campaignCreate($apikey, $type, $opts, $content, $seg);
- } catch (XML_RPC2_FaultException $e){
- }
- <?php
- /**
- This Example shows how create an A/B Split campaign using XML-RPC.
- Note that we are using the PEAR XML-RPC client and recommend others do as well.
- **/
- require_once 'XML/RPC2/Client.php';
- require_once 'inc/config.inc.php';
- try {
- $opts['list_id'] = $listId;
- $opts['subject'] = 'hello thar!';
- $opts['from_email'] = $my_email;
- $opts['from_name'] = 'My Name';
- 'text_clicks' => false);
- $opts['authenticate'] = false;
- $opts['title'] = 'My 123 Campaign';
- 'text' => 'text text text *|UNSUB|*');
- //no segmentation on this one.
- $type = "absplit";
- $type_opts['split_test'] = 'schedule';
- $type_opts['pick_winner'] = 'manual';
- $type_opts['from_name_a'] = 'Wahoo McDaniels';
- $type_opts['from_email_a'] = 'wahoo@example.org';
- $type_opts['from_name_b'] = 'Yahoo McDonald';
- $type_opts['from_email_b'] = 'yahoo@example.org';
- $result = $client->campaignCreate($apikey, $type, $opts, $content, $seg, $type_opts);
- } catch (XML_RPC2_FaultException $e){
- }
- <?php
- /**
- This Example shows how create a RSS campaign using XML-RPC.
- Note that we are using the PEAR XML-RPC client and recommend others do as well.
- **/
- require_once 'XML/RPC2/Client.php';
- require_once 'inc/config.inc.php';
- try {
- $opts['list_id'] = $listId;
- $opts['subject'] = 'hello thar!';
- $opts['from_email'] = $my_email;
- $opts['from_name'] = 'My Name';
- 'text_clicks' => false);
- $opts['authenticate'] = false;
- $opts['title'] = 'My 123 Campaign';
- 'text' => 'text text text *|UNSUB|*');
- //no segmentation on this one.
- $type = 'rss';
- $type_opts['url'] = 'http://mailchimp.com/blog/rss';
- $result = $client->campaignCreate($apikey, $type, $opts, $content, $seg, $type_opts);
- } catch (XML_RPC2_FaultException $e){
- }
Examples (4)
download example code[1] mcapi_campaignCreate.php
[2] xml-rpc_campaignCreate.php
[3] xml-rpc_campaignCreateABSplit.php
[4] xml-rpc_campaignCreateRss.php
|
Add New Note
User Contributed Notes for
campaignCreate |
|---|
| No notes, yet... Will you be the first?? |