Back to Documentation Overview
campaignCreate
public static campaignCreate(string uid, string list_id, string subject, string from_email, string from_name, array content, integer template_id, array tracking, boolean authenticate, string analytics, string title)
Create a new draft campaign to send
- Section:
- Campaign Related
- Parameters:
uid the id for your user account. Get by calling login($user, $pass) list_id the list to send this campaign to- get lists using getLists() subject the subject line for your campaign message from_email the From: email address for your campaign message from_name the From: name for your campaign message content the content for this campaign - use a struct with the following keys: "html" for pasted HTML content and "text" for the plain-text version. 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" template_id optional - use this template to generate the HTML content of the campaign 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. title optional - an internal name to use for this campaign. By default, the campaign subject will be used. authenticate optional - set to true to enable SenderID, DomainKeys, and DKIM authentication, defaults to false 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 - Returns:
- string - the ID for the created campaign
- <?php
- /**
- This Example shows how to Create a Campgaign using the MCAPI.php class using
- a template to set custom content sections and do some basic error checking.
- **/
- // Include the MailChimp API code. Do Not Edit This!
- include('inc/MCAPI.class.php');
- include('config.inc');
- // Connect to the MailChimp server with the user's credentials.
- $list_id = 'XXXXXXXX';
- $subject = 'My Newsletter Test';
- $title = 'Test - newsletter';
- $from_email = 'coyote@acmeinc.org';
- $from_name = 'ACME, Inc.';
- //Note: the 4 "html_" section values shown are the only ones supported
- '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|*'
- );
- $template_id = "1";
- $authenticate = false;
- $cid = $acct->campaignCreate($list_id, $subject, $from_email, $from_name,
- $content, $template_id, $tracking, $title,
- $authenticate, $analytics);
- if (!$cid){
- } else {
- }
- ?>
- <?php
- /**
- This Example shows how to use the XML-RPC service to create a new Campaign
- and do some basic error checking.
- Note that we are using the PEAR XML-RPC client and recommend others do as well.
- **/
- require_once 'XML/RPC2/Client.php';
- include('inc/config.inc.php'); //contains username & password
- $uuid = $client->login($username,$password);
- $subject = 'My Newsletter Test';
- $title = 'Test - newsletter';
- $from_email = 'coyote@acmeinc.org';
- $from_name = 'ACME, Inc.';
- 'text' => 'text text text *|UNSUB|*'
- );
- $template_id = "";
- $authenticate = false;
- try {
- //parameters wrapped to fit the page...
- $result = $client->campaignCreate($uuid, $list_id, $subject, $from_email, $from_name,
- $content, $template_id, $tracking, $title,
- $authenticate, $analytics);
- } catch (XML_RPC2_FaultException $e){
- }
- ?>
Examples (2)
download example code[1] mcapi_campaignCreate.php
[2] xml-rpc_createCampaign.php
|
Add New Note
User Contributed Notes for
campaignCreate |
|---|
| No notes, yet... Will you be the first?? |