2013-04-02 80 views
4

Mailchimp將每個表單關聯到一個列表。Mailchimp的一個列表,兩個不同的感謝頁面

我想在Page1.html上有一個註冊表單,它將用戶發送給Page1ty.html,並在Page2.html上發送用戶給Page2ty.html的另一個表單。但是這兩種形式都需要將用戶提供給相同的列表。如上所述,這是不可能的,使用他們的基本形式。我需要兩個列表。

Mailchimp說這種路由可能使用他們的API。有沒有人知道如何去完成上述類型的註冊?

回答

6

您只需創建自定義表單並綁定到MailChimp API中,但從最新更新開始,您需要確保您擁有管理員權限。

您包括(需要)MCAPI.class.phpconfig.inc.php文件從他們的API downloads,然後編寫您的過程(我使用PHP)。

一旦您下載了文件並使用正確的憑證(API密鑰和列表ID)設置了您的'config.inc.php`文件,您就可以開始使用了。

下面是PHP中的一個示例,該示例將用戶訂閱到列表中,但您必須閱讀API文檔才能獲得所需的確切功能。

<?php 
session_start(); 

// --- Sample fields - depends on your list 
$mailChimpTIME = date('Y-m-d H:i:s'); 
$mailChimpFirstName = // First Name 
$mailChimpLastName = // Last Name 
$mailChimpEmailAddress = // Email Address 

require_once 'MCAPI.class.php'; 
require_once 'config.inc.php'; //contains apikey 

$api = new MCAPI($apikey); 

$merge_vars = array(
'FNAME'=>$mailChimpFirstName, 
'LNAME'=>$mailChimpLastName, 
'EMAIL'=>$mailChimpEmailAddress, 
'OPTIN_IP'=>$_SERVER['REMOTE_ADDR'], 
'OPTIN_TIME'=>$mailChimpTIME 
); 

$email_type = 'html'; 
$double_optin = true; 
$update_existing = true; 
$replace_interests = false; 

// By default this sends a confirmation email - you will not see new members 
// until the link contained in it is clicked! 
$retval = $api->listSubscribe($listId, $mailChimpEmailAddress, $merge_vars, $email_type, $double_optin, $update_existing, $replace_interests); 

if ($api->errorCode){ 
    echo "Unable to load listSubscribe()!\n"; 
    echo "\tCode=".$api->errorCode."\n"; 
    echo "\tMsg=".$api->errorMessage."\n"; 
} else { 
    // Success 
    //echo "Subscribed - look for the confirmation email!\n"; 
} 
?> 
相關問題