### Manually Install Mailchimp Marketing PHP Source: https://github.com/mailchimp/mailchimp-marketing-php/blob/master/README.md Provides steps for manually installing the Mailchimp Marketing PHP client library by cloning the repository and installing dependencies. This method is an alternative to using Composer for installation. ```bash git clone git@github.com:mailchimp/mailchimp-marketing-php.git ``` ```bash composer install ``` -------------------------------- ### Install Mailchimp Marketing PHP SDK via Composer Source: https://context7.com/mailchimp/mailchimp-marketing-php/llms.txt Installs the Mailchimp Marketing PHP SDK using Composer. This is the recommended method for integrating the SDK into your PHP application. ```bash composer require mailchimp/marketing ``` ```json { "require": { "mailchimp/marketing": "*" } } ``` -------------------------------- ### Install Mailchimp Marketing PHP via Composer Source: https://github.com/mailchimp/mailchimp-marketing-php/blob/master/README.md Installs the Mailchimp Marketing PHP client library using Composer. This is the recommended method for managing dependencies. It requires Composer to be installed on your system. ```bash composer require mailchimp/marketing ``` ```json { "require": { "mailchimp/marketing": "*" } } ``` ```bash composer install ``` -------------------------------- ### Quick Start: Initialize Mailchimp API Client in PHP Source: https://github.com/mailchimp/mailchimp-marketing-php/blob/master/README.md Demonstrates the basic initialization of the Mailchimp Marketing API client in PHP. It requires PHP 7.2 or above and sets up the API key and server prefix for authentication. ```php require_once('/path/to/MailchimpMarketing/vendor/autoload.php'); $mailchimp = new MailchimpMarketing\ApiClient(); $mailchimp->setConfig([ 'apiKey' => 'YOUR_API_KEY', 'server' => 'YOUR_SERVER_PREFIX' ]); $response = $mailchimp->ping->get(); print_r($response); ``` -------------------------------- ### Get Campaign Content and Send Checklist Source: https://context7.com/mailchimp/mailchimp-marketing-php/llms.txt Retrieves current campaign content or checks if a campaign meets all requirements for sending. Useful for pre-flight validation. ```php $campaignId = 'abc123'; // Get content $response = $mailchimp->campaigns->getContent($campaignId); // Get checklist $checklist = $mailchimp->campaigns->getSendChecklist($campaignId); echo "Ready to send: " . ($checklist->is_ready ? 'Yes' : 'No'); ``` -------------------------------- ### Get Specific Automation Details in Mailchimp PHP Source: https://context7.com/mailchimp/mailchimp-marketing-php/llms.txt Fetches detailed information for a specific automation workflow using its unique ID. The output includes the automation's title, status, associated list ID, trigger type, creation time, and start time. Requires the Mailchimp PHP client. ```php automations->get($workflowId); echo "Automation: {$response->settings->title}\n"; echo "Status: {$response->status}\n"; echo "List ID: {$response->recipients->list_id}\n"; echo "Trigger: {$response->trigger_settings->workflow_type}\n"; echo "Created: {$response->create_time}\n"; echo "Start time: {$response->start_time}\n"; ?> ``` -------------------------------- ### GET /lists Source: https://github.com/mailchimp/mailchimp-marketing-php/blob/master/README.md Retrieve all audience lists associated with the authenticated account. ```APIDOC ## GET /lists ### Description Retrieve all audience lists associated with the authenticated account. ### Method GET ### Endpoint /lists ### Response #### Success Response (200) - **lists** (array) - A list of audience objects. #### Response Example { "lists": [ { "id": "123", "name": "My List" } ] } ``` -------------------------------- ### Include Autoloader in PHP Implementation Source: https://github.com/mailchimp/mailchimp-marketing-php/blob/master/README.md Manually includes the Composer autoloader file in your PHP script. This is necessary when you install the library manually and need to use its classes. ```php require_once('/path/to/MailchimpMarketing/vendor/autoload.php'); ``` -------------------------------- ### GET /ping Source: https://github.com/mailchimp/mailchimp-marketing-php/blob/master/README.md Checks the status of the Mailchimp API connection. ```APIDOC ## GET /ping ### Description Returns a health check status for the Mailchimp API. ### Method GET ### Endpoint /ping ### Response #### Success Response (200) - **health_status** (string) - The status message, typically 'Everything's Chimpy!'. #### Response Example { "health_status": "Everything's Chimpy!" } ``` -------------------------------- ### E-commerce API - Get Operations Source: https://github.com/mailchimp/mailchimp-marketing-php/blob/master/README.md Endpoints for retrieving various e-commerce resources such as stores, carts, products, orders, customers, and promotions. ```APIDOC ## GET /ecommerce/orders ### Description Retrieves a list of all orders across all stores. This might be a high-level overview or require store context depending on the API's implementation. ### Method GET ### Endpoint /ecommerce/orders ### Parameters #### Query Parameters - **fields** (array) - Optional - Comma-separated list of fields to return. - **exclude_fields** (array) - Optional - Comma-separated list of fields to exclude. - **count** (integer) - Optional - The number of results to return. - **offset** (integer) - Optional - The starting point of the results. - **sort_by** (string) - Optional - Field to sort results by. - **sort_dir** (string) - Optional - Direction of sorting ('asc' or 'desc'). ### Request Example ```json { "example": "No request body. Use query parameters for filtering and pagination." } ``` ### Response #### Success Response (200) - **orders** (array) - A list of order objects. - **total_items** (integer) - The total number of orders available. #### Response Example ```json { "example": { "orders": [ { "order_id": "string", "store_id": "string", "customer_id": "string", "order_total": 0.0, "currency_code": "string", "processed_at_ அளவு": "string" } ], "total_items": 100 } } ``` ## GET /ecommerce/stores ### Description Retrieves a list of all e-commerce stores. ### Method GET ### Endpoint /ecommerce/stores ### Parameters #### Query Parameters - **fields** (array) - Optional - Comma-separated list of fields to return. - **exclude_fields** (array) - Optional - Comma-separated list of fields to exclude. - **count** (integer) - Optional - The number of results to return. - **offset** (integer) - Optional - The starting point of the results. ### Request Example ```json { "example": "No request body. Use query parameters for filtering and pagination." } ``` ### Response #### Success Response (200) - **stores** (array) - A list of store objects. - **total_items** (integer) - The total number of stores available. #### Response Example ```json { "example": { "stores": [ { "store_id": "string", "name": "string", "domain": "string" } ], "total_items": 50 } } ``` ## GET /ecommerce/stores/{store_id} ### Description Retrieves details for a specific e-commerce store. ### Method GET ### Endpoint /ecommerce/stores/{store_id} ### Parameters #### Path Parameters - **store_id** (string) - Required - The ID of the store to retrieve. #### Query Parameters - **fields** (array) - Optional - Comma-separated list of fields to return. - **exclude_fields** (array) - Optional - Comma-separated list of fields to exclude. ### Request Example ```json { "example": "No request body. Use path parameters for store ID." } ``` ### Response #### Success Response (200) - **store_id** (string) - The ID of the store. - **name** (string) - The name of the store. - **domain** (string) - The domain of the store. #### Response Example ```json { "example": { "store_id": "string", "name": "string", "domain": "string" } } ``` ## GET /ecommerce/stores/{store_id}/carts ### Description Retrieves a list of all shopping carts for a specific store. ### Method GET ### Endpoint /ecommerce/stores/{store_id}/carts ### Parameters #### Path Parameters - **store_id** (string) - Required - The ID of the store. #### Query Parameters - **fields** (array) - Optional - Comma-separated list of fields to return. - **exclude_fields** (array) - Optional - Comma-separated list of fields to exclude. - **count** (integer) - Optional - The number of results to return. - **offset** (integer) - Optional - The starting point of the results. ### Request Example ```json { "example": "No request body. Use path parameters for store ID and query parameters for filtering." } ``` ### Response #### Success Response (200) - **carts** (array) - A list of cart objects. - **total_items** (integer) - The total number of carts available. #### Response Example ```json { "example": { "carts": [ { "cart_id": "string", "customer_id": "string", "created_at": "string" } ], "total_items": 20 } } ``` ## GET /ecommerce/stores/{store_id}/carts/{cart_id} ### Description Retrieves details for a specific shopping cart. ### Method GET ### Endpoint /ecommerce/stores/{store_id}/carts/{cart_id} ### Parameters #### Path Parameters - **store_id** (string) - Required - The ID of the store. - **cart_id** (string) - Required - The ID of the cart to retrieve. #### Query Parameters - **fields** (array) - Optional - Comma-separated list of fields to return. - **exclude_fields** (array) - Optional - Comma-separated list of fields to exclude. ### Request Example ```json { "example": "No request body. Use path parameters for store and cart IDs." } ``` ### Response #### Success Response (200) - **cart_id** (string) - The ID of the cart. - **customer_id** (string) - The ID of the customer associated with the cart. - **created_at** (string) - The timestamp when the cart was created. #### Response Example ```json { "example": { "cart_id": "string", "customer_id": "string", "created_at": "string" } } ``` ## GET /ecommerce/stores/{store_id}/carts/{cart_id}/lines ### Description Retrieves all line items within a specific shopping cart. ### Method GET ### Endpoint /ecommerce/stores/{store_id}/carts/{cart_id}/lines ### Parameters #### Path Parameters - **store_id** (string) - Required - The ID of the store. - **cart_id** (string) - Required - The ID of the cart. #### Query Parameters - **fields** (array) - Optional - Comma-separated list of fields to return. - **exclude_fields** (array) - Optional - Comma-separated list of fields to exclude. - **count** (integer) - Optional - The number of results to return. - **offset** (integer) - Optional - The starting point of the results. ### Request Example ```json { "example": "No request body. Use path parameters for store and cart IDs." } ``` ### Response #### Success Response (200) - **lines** (array) - A list of line item objects. - **total_items** (integer) - The total number of line items available. #### Response Example ```json { "example": { "lines": [ { "line_id": "string", "product_id": "string", "quantity": 1 } ], "total_items": 5 } } ``` ## GET /ecommerce/stores/{store_id}/carts/{cart_id}/lines/{line_id} ### Description Retrieves a specific line item from a shopping cart. ### Method GET ### Endpoint /ecommerce/stores/{store_id}/carts/{cart_id}/lines/{line_id} ### Parameters #### Path Parameters - **store_id** (string) - Required - The ID of the store. - **cart_id** (string) - Required - The ID of the cart. - **line_id** (string) - Required - The ID of the line item to retrieve. #### Query Parameters - **fields** (array) - Optional - Comma-separated list of fields to return. - **exclude_fields** (array) - Optional - Comma-separated list of fields to exclude. ### Request Example ```json { "example": "No request body. Use path parameters for store, cart, and line item IDs." } ``` ### Response #### Success Response (200) - **line_id** (string) - The ID of the line item. - **product_id** (string) - The ID of the product in the line item. - **quantity** (integer) - The quantity of the product. #### Response Example ```json { "example": { "line_id": "string", "product_id": "string", "quantity": 1 } } ``` ## GET /ecommerce/stores/{store_id}/customers ### Description Retrieves a list of all customers for a specific store. ### Method GET ### Endpoint /ecommerce/stores/{store_id}/customers ### Parameters #### Path Parameters - **store_id** (string) - Required - The ID of the store. #### Query Parameters - **fields** (array) - Optional - Comma-separated list of fields to return. - **exclude_fields** (array) - Optional - Comma-separated list of fields to exclude. - **count** (integer) - Optional - The number of results to return. - **offset** (integer) - Optional - The starting point of the results. ### Request Example ```json { "example": "No request body. Use path parameters for store ID and query parameters for filtering." } ``` ### Response #### Success Response (200) - **customers** (array) - A list of customer objects. - **total_items** (integer) - The total number of customers available. #### Response Example ```json { "example": { "customers": [ { "customer_id": "string", "email_address": "string", "first_name": "string" } ], "total_items": 150 } } ``` ## GET /ecommerce/stores/{store_id}/customers/{customer_id} ### Description Retrieves details for a specific customer. ### Method GET ### Endpoint /ecommerce/stores/{store_id}/customers/{customer_id} ### Parameters #### Path Parameters - **store_id** (string) - Required - The ID of the store. - **customer_id** (string) - Required - The ID of the customer to retrieve. #### Query Parameters - **fields** (array) - Optional - Comma-separated list of fields to return. - **exclude_fields** (array) - Optional - Comma-separated list of fields to exclude. ### Request Example ```json { "example": "No request body. Use path parameters for store and customer IDs." } ``` ### Response #### Success Response (200) - **customer_id** (string) - The ID of the customer. - **email_address** (string) - The email address of the customer. - **first_name** (string) - The first name of the customer. #### Response Example ```json { "example": { "customer_id": "string", "email_address": "string", "first_name": "string" } } ``` ## GET /ecommerce/stores/{store_id}/orders ### Description Retrieves a list of orders for a specific store. ### Method GET ### Endpoint /ecommerce/stores/{store_id}/orders ### Parameters #### Path Parameters - **store_id** (string) - Required - The ID of the store. #### Query Parameters - **fields** (array) - Optional - Comma-separated list of fields to return. - **exclude_fields** (array) - Optional - Comma-separated list of fields to exclude. - **count** (integer) - Optional - The number of results to return. - **offset** (integer) - Optional - The starting point of the results. - **sort_by** (string) - Optional - Field to sort results by. - **sort_dir** (string) - Optional - Direction of sorting ('asc' or 'desc'). ### Request Example ```json { "example": "No request body. Use path parameters for store ID and query parameters for filtering." } ``` ### Response #### Success Response (200) - **orders** (array) - A list of order objects. - **total_items** (integer) - The total number of orders available. #### Response Example ```json { "example": { "orders": [ { "order_id": "string", "customer_id": "string", "order_total": 0.0, "currency_code": "string" } ], "total_items": 75 } } ``` ## GET /ecommerce/stores/{store_id}/orders/{order_id} ### Description Retrieves details for a specific order. ### Method GET ### Endpoint /ecommerce/stores/{store_id}/orders/{order_id} ### Parameters #### Path Parameters - **store_id** (string) - Required - The ID of the store. - **order_id** (string) - Required - The ID of the order to retrieve. #### Query Parameters - **fields** (array) - Optional - Comma-separated list of fields to return. - **exclude_fields** (array) - Optional - Comma-separated list of fields to exclude. ### Request Example ```json { "example": "No request body. Use path parameters for store and order IDs." } ``` ### Response #### Success Response (200) - **order_id** (string) - The ID of the order. - **customer_id** (string) - The ID of the customer who placed the order. - **order_total** (number) - The total amount of the order. - **currency_code** (string) - The currency code for the order total. #### Response Example ```json { "example": { "order_id": "string", "customer_id": "string", "order_total": 120.50, "currency_code": "USD" } } ``` ## GET /ecommerce/stores/{store_id}/orders/{order_id}/lines ### Description Retrieves all line items for a specific order. ### Method GET ### Endpoint /ecommerce/stores/{store_id}/orders/{order_id}/lines ### Parameters #### Path Parameters - **store_id** (string) - Required - The ID of the store. - **order_id** (string) - Required - The ID of the order. #### Query Parameters - **fields** (array) - Optional - Comma-separated list of fields to return. - **exclude_fields** (array) - Optional - Comma-separated list of fields to exclude. - **count** (integer) - Optional - The number of results to return. - **offset** (integer) - Optional - The starting point of the results. ### Request Example ```json { "example": "No request body. Use path parameters for store and order IDs." } ``` ### Response #### Success Response (200) - **lines** (array) - A list of order line item objects. - **total_items** (integer) - The total number of line items available. #### Response Example ```json { "example": { "lines": [ { "line_id": "string", "product_id": "string", "quantity": 2 } ], "total_items": 3 } } ``` ## GET /ecommerce/stores/{store_id}/orders/{order_id}/lines/{line_id} ### Description Retrieves a specific line item from an order. ### Method GET ### Endpoint /ecommerce/stores/{store_id}/orders/{order_id}/lines/{line_id} ### Parameters #### Path Parameters - **store_id** (string) - Required - The ID of the store. - **order_id** (string) - Required - The ID of the order. - **line_id** (string) - Required - The ID of the line item to retrieve. #### Query Parameters - **fields** (array) - Optional - Comma-separated list of fields to return. - **exclude_fields** (array) - Optional - Comma-separated list of fields to exclude. ### Request Example ```json { "example": "No request body. Use path parameters for store, order, and line item IDs." } ``` ### Response #### Success Response (200) - **line_id** (string) - The ID of the line item. - **product_id** (string) - The ID of the product in the line item. - **quantity** (integer) - The quantity of the product. #### Response Example ```json { "example": { "line_id": "string", "product_id": "string", "quantity": 2 } } ``` ## GET /ecommerce/stores/{store_id}/products ### Description Retrieves a list of all products for a specific store. ### Method GET ### Endpoint /ecommerce/stores/{store_id}/products ### Parameters #### Path Parameters - **store_id** (string) - Required - The ID of the store. #### Query Parameters - **fields** (array) - Optional - Comma-separated list of fields to return. - **exclude_fields** (array) - Optional - Comma-separated list ``` -------------------------------- ### Get All Mailchimp Campaign Reports Source: https://context7.com/mailchimp/mailchimp-marketing-php/llms.txt Retrieves performance reports for all campaigns. Allows filtering by campaign type and time range. Returns a list of reports including campaign title, emails sent, open rate, click rate, and unsubscribes. Supports pagination. ```php reports->getAllCampaignReports( null, // fields null, // exclude_fields 10, // count 0, // offset 'regular', // type null, // before_send_time null // since_send_time ); foreach ($response->reports as $report) { echo "Campaign: {$report->campaign_title}\n"; echo "Emails sent: {$report->emails_sent}\n"; echo "Open rate: " . number_format($report->opens->open_rate * 100, 2) . "%\n"; echo "Click rate: " . number_format($report->clicks->click_rate * 100, 2) . "%\n"; echo "Unsubscribes: {$report->unsubscribed}\n"; echo "---\n"; } ?> ``` -------------------------------- ### Start/Pause Automation Emails in Mailchimp PHP Source: https://context7.com/mailchimp/mailchimp-marketing-php/llms.txt Provides functionality to control the status of automation workflows and individual emails. It can start or pause all emails within an automation, or target specific emails by their IDs. This requires the Mailchimp PHP client library. ```php automations->startAllEmails($workflowId); echo "Automation started\n"; // Pause all emails $mailchimp->automations->pauseAllEmails($workflowId); echo "Automation paused\n"; // Start/pause individual emails $emailId = 'def456'; $mailchimp->automations->startWorkflowEmail($workflowId, $emailId); $mailchimp->automations->pauseWorkflowEmail($workflowId, $emailId); ?> ``` -------------------------------- ### Initialize Mailchimp Client with Basic Authentication (API Key) Source: https://context7.com/mailchimp/mailchimp-marketing-php/llms.txt Initializes the Mailchimp Marketing API client using basic authentication with an API key and server prefix. It then verifies the connection by pinging the API. ```php setConfig([ 'apiKey' => 'your-api-key-us19', 'server' => 'us19' // Extract from API key suffix ]); // Verify connection $response = $mailchimp->ping->get(); print_r($response); // Output: stdClass Object ( [health_status] => Everything's Chimpy! ) ``` -------------------------------- ### Manage Campaign Lifecycle Source: https://context7.com/mailchimp/mailchimp-marketing-php/llms.txt Provides methods to send a campaign immediately, replicate an existing campaign, or pause/resume RSS-driven campaigns. ```php $campaignId = 'abc123'; // Send immediately $mailchimp->campaigns->send($campaignId); // Replicate $copy = $mailchimp->campaigns->replicate($campaignId); // Pause/Resume $mailchimp->campaigns->pause($campaignId); $mailchimp->campaigns->resume($campaignId); ``` -------------------------------- ### Create a Campaign with Mailchimp PHP Source: https://context7.com/mailchimp/mailchimp-marketing-php/llms.txt Initializes a new regular email campaign linked to a specific audience list. Requires configuration of recipient settings, campaign metadata, and tracking preferences. ```php $response = $mailchimp->campaigns->create([ 'type' => 'regular', 'recipients' => [ 'list_id' => 'abc123def4', 'segment_opts' => [ 'saved_segment_id' => 12345, 'match' => 'any' ] ], 'settings' => [ 'subject_line' => 'Your Monthly Newsletter', 'preview_text' => 'Check out what\'s new this month!', 'title' => 'March 2024 Newsletter', 'from_name' => 'My Company', 'reply_to' => 'hello@example.com', 'to_name' => '*|FNAME|*', 'auto_footer' => true, 'inline_css' => true, 'authenticate' => true, 'timewarp' => false, 'auto_tweet' => false ], 'tracking' => [ 'opens' => true, 'html_clicks' => true, 'text_clicks' => true, 'goal_tracking' => false, 'ecomm360' => true, 'google_analytics' => 'march_newsletter_2024' ] ]); echo "Created campaign: {$response->id}\n"; echo "Web ID: {$response->web_id}\n"; ``` -------------------------------- ### GET /reports/{campaign_id} Source: https://github.com/mailchimp/mailchimp-marketing-php/blob/master/README.md Retrieves detailed report information for a specific campaign. ```APIDOC ## GET /reports/{campaign_id} ### Description Get a summary report for a specific campaign. ### Method GET ### Endpoint /reports/{campaign_id} ### Parameters #### Path Parameters - **campaign_id** (string) - Required - The unique ID for the campaign. ### Response #### Success Response (200) - **id** (string) - The campaign ID. - **emails_sent** (integer) - Total emails sent. - **abuse_reports** (integer) - Total abuse reports. #### Response Example { "id": "c123", "emails_sent": 1500, "abuse_reports": 0 } ``` -------------------------------- ### Configure Advanced Mailchimp Client Options Source: https://context7.com/mailchimp/mailchimp-marketing-php/llms.txt Demonstrates advanced configuration for the Mailchimp Marketing API client, including setting a custom timeout, enabling debug mode with a specified log file, and setting a custom user agent. ```php setConfig([ 'apiKey' => 'your-api-key-us19', 'server' => 'us19', 'timeout' => 300 // Custom timeout in seconds ]); // Enable debug mode for troubleshooting $mailchimp->setDebug(true); $mailchimp->setDebugFile('/var/log/mailchimp-debug.log'); // Custom user agent $mailchimp->setUserAgent('MyApp/1.0'); ``` -------------------------------- ### GET /lists/{list_id}/members/{subscriber_hash} Source: https://github.com/mailchimp/mailchimp-marketing-php/blob/master/README.md Retrieve information about a specific member within a Mailchimp list. ```APIDOC ## GET /lists/{list_id}/members/{subscriber_hash} ### Description Retrieve information about a specific member within a Mailchimp list using the subscriber hash. ### Method GET ### Endpoint /lists/{list_id}/members/{subscriber_hash} ### Parameters #### Path Parameters - **list_id** (string) - Required - The unique ID for the list. - **subscriber_hash** (string) - Required - The MD5 hash of the lowercase version of the list member's email address. ### Response #### Success Response (200) - **email_address** (string) - The email address of the subscriber. - **status** (string) - The subscription status of the member. #### Response Example { "email_address": "user@example.com", "status": "subscribed" } ``` -------------------------------- ### POST /verified-domains/{domain_name}/actions/verify Source: https://context7.com/mailchimp/mailchimp-marketing-php/llms.txt Submit a request to verify a previously added domain. ```APIDOC ## POST /verified-domains/{domain_name}/actions/verify ### Description Initiates the verification process for a domain that has already been added to the account. ### Method POST ### Endpoint /verified-domains/{domain_name}/actions/verify ### Parameters #### Path Parameters - **domain_name** (string) - Required - The domain name to verify. ### Request Example { "domain_name": "example.com" } ### Response #### Success Response (204) - No content returned upon successful submission. ``` -------------------------------- ### Initialize Mailchimp Client with OAuth2 Authentication Source: https://context7.com/mailchimp/mailchimp-marketing-php/llms.txt Initializes the Mailchimp Marketing API client using OAuth2 authentication with an access token and server prefix. It tests the connection by pinging the API. ```php setConfig([ 'accessToken' => 'your-oauth-access-token', 'server' => 'us19' ]); // Test the connection $response = $mailchimp->ping->get(); print_r($response); ``` -------------------------------- ### List All Batches with Mailchimp PHP Source: https://context7.com/mailchimp/mailchimp-marketing-php/llms.txt Fetches a paginated list of all batch operations submitted to the Mailchimp API. ```php $response = $mailchimp->batches->list( null, null, 10, 0 ); foreach ($response->batches as $batch) { echo "Batch: {$batch->id}\n"; echo "Status: {$batch->status}\n"; echo "Submitted: {$batch->submitted_at}\n"; echo "---\n"; } ``` -------------------------------- ### Get Campaign Recipients and Unsubscribes Source: https://context7.com/mailchimp/mailchimp-marketing-php/llms.txt Retrieves lists of recipients or unsubscribed users for a specific campaign. These methods require a valid campaign ID and return objects containing status and metadata. ```php $campaignId = 'abc123'; $response = $mailchimp->reports->getCampaignRecipients( $campaignId, null, null, 100, 0 ); foreach ($response->sent_to as $recipient) { echo "Email: {$recipient->email_address}\n"; echo "Status: {$recipient->status}\n"; echo "Open count: {$recipient->open_count}\n"; echo "Last open: {$recipient->last_open}\n"; echo "---\n"; } ``` ```php $campaignId = 'abc123'; $response = $mailchimp->reports->getUnsubscribedListForCampaign( $campaignId, null, null, 100, 0 ); foreach ($response->unsubscribes as $unsub) { echo "Email: {$unsub->email_address}\n"; echo "Reason: {$unsub->reason}\n"; echo "Timestamp: {$unsub->timestamp}\n"; echo "---\n"; } ``` -------------------------------- ### Manage Landing Pages with Mailchimp PHP Source: https://context7.com/mailchimp/mailchimp-marketing-php/llms.txt Covers listing, creating, publishing, and unpublishing landing pages within a Mailchimp account. ```php // List Landing Pages $response = $mailchimp->landingPages->getAll('all', null, null, null, 10); // Create Landing Page $response = $mailchimp->landingPages->create([ 'name' => 'Spring Sale Landing Page', 'title' => 'Spring Sale - 20% Off Everything', 'list_id' => 'abc123def4', 'template_id' => 12345 ]); // Publish/Unpublish $mailchimp->landingPages->publishPage('page123'); $mailchimp->landingPages->unpublishPage('page123'); ``` -------------------------------- ### Get All Mailchimp Lists (Audiences) with Pagination Source: https://context7.com/mailchimp/mailchimp-marketing-php/llms.txt Retrieves all audience lists from a Mailchimp account using optional filtering and pagination parameters. It iterates through the lists and prints their names, IDs, and member counts. ```php lists->getAllLists( null, // fields - specific fields to return null, // exclude_fields 10, // count - number of records 0, // offset - pagination offset null, // before_date_created null, // since_date_created null, // before_campaign_last_sent null, // since_campaign_last_sent null, // email 'asc', // sort_field 'created_date' // sort_dir ); foreach ($response->lists as $list) { echo "List: {$list->name} (ID: {$list->id})\n"; echo "Members: {$list->stats->member_count}\n"; echo "---\n"; } ``` -------------------------------- ### Send Test Email and Schedule Campaigns Source: https://context7.com/mailchimp/mailchimp-marketing-php/llms.txt Sends a test email to specified addresses or schedules a campaign for a future date. Supports batch delivery options. ```php $campaignId = 'abc123'; // Send test $mailchimp->campaigns->sendTestEmail($campaignId, ['test_emails' => ['test1@example.com'], 'send_type' => 'html']); // Schedule $mailchimp->campaigns->schedule($campaignId, [ 'schedule_time' => '2024-03-15T10:00:00+00:00', 'batch_delivery' => ['batch_delay' => 5, 'batch_count' => 10] ]); ``` -------------------------------- ### Execute Batch Operations with Mailchimp PHP Source: https://context7.com/mailchimp/mailchimp-marketing-php/llms.txt Demonstrates how to group multiple API operations into a single batch request to improve efficiency. It includes creating members and updating merge fields within a single batch. ```php $response = $mailchimp->batches->start([ 'operations' => [ [ 'method' => 'POST', 'path' => '/lists/abc123/members', 'body' => json_encode([ 'email_address' => 'user1@example.com', 'status' => 'subscribed' ]) ], [ 'method' => 'POST', 'path' => '/lists/abc123/members', 'body' => json_encode([ 'email_address' => 'user2@example.com', 'status' => 'subscribed' ]) ], [ 'method' => 'PATCH', 'path' => '/lists/abc123/members/' . md5('existing@example.com'), 'body' => json_encode([ 'merge_fields' => ['FNAME' => 'Updated'] ]) ] ] ]); echo "Batch started: {$response->id}\n"; echo "Status: {$response->status}\n"; ``` -------------------------------- ### Manage Email Templates Source: https://context7.com/mailchimp/mailchimp-marketing-php/llms.txt Provides functionality to list, create, retrieve default content, and update email templates. These operations allow for dynamic management of account-level email designs. ```php $response = $mailchimp->templates->list(null, null, 10, 0, null, null, null, 'user', null, null, 'date_created', 'DESC'); foreach ($response->templates as $template) { echo "Template: {$template->name}\n"; echo "ID: {$template->id}\n"; echo "Type: {$template->type}\n"; echo "Created: {$template->date_created}\n"; echo "---\n"; } ``` ```php $response = $mailchimp->templates->create([ 'name' => 'Monthly Newsletter Template', 'folder_id' => '12345', 'html' => '