本文整理汇总了PHP中MCAPI::listMergeVarAdd方法的典型用法代码示例。如果您正苦于以下问题:PHP MCAPI::listMergeVarAdd方法的具体用法?PHP MCAPI::listMergeVarAdd怎么用?PHP MCAPI::listMergeVarAdd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MCAPI
的用法示例。
在下文中一共展示了MCAPI::listMergeVarAdd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateSettings
function updateSettings($variables)
{
if (!isset($variables["mailchimp_secure"])) {
$variables["mailchimp_secure"] = 0;
}
/**
* Check for a valid api key.
*/
if ($variables["apikey_changed"] == "1" && $variables["mailchimp_apikey"] != "") {
include_once "include/MCAPI.class.php";
$api = new MCAPI($variables["mailchimp_apikey"]);
$api->ping();
if ($api->errorCode) {
unset($variables["mailchimp_apikey"]);
$this->updateErrorMessage = "Unable to change the MailChimp apikey: " . $api->errorMessage . " (" . $api->errorCode . ")";
return $variables;
}
//end if
}
//end if
/**
* Check for valid list id
*/
if ($variables["apilist_changed"] == "1" && $variables["mailchimp_list_id"] != "") {
include_once "include/MCAPI.class.php";
/**
* Check to see if api is already defined (from a possible api key check)
* If not, define it and check the key/connection
*/
if (!isset($api)) {
$api = new MCAPI($variables["mailchimp_apikey"]);
$api->ping();
if ($api->errorCode) {
unset($variables["mailchimp_list_id"]);
$this->updateErrorMessage = "Unable to change the MailChimp list id: " . $api->errorMessage . " (" . $api->errorCode . ")";
return $variables;
}
//end if
}
//end if
/**
* Look up the lists
*/
$lists = $api->lists();
if ($api->errorCode) {
unset($variables["mailchimp_list_id"]);
$this->updateErrorMessage = "Unable to change the MailChimp list id: " . $api->errorMessage . " (" . $api->errorCode . ")";
return $variables;
} else {
/**
* Check to see if list id is valid
*/
$validId = false;
foreach ($lists as $list) {
if ($list["id"] == $variables["mailchimp_list_id"]) {
$validId = true;
break;
}
}
//endif
if (!$validId) {
unset($variables["mailchimp_list_id"]);
$this->updateErrorMessage = "Unable to change the MailChimp list id: the id does not match a valid id on the account.";
return $variables;
} else {
/**
* Check to see if the list has a uuid.
*/
$hasUuid = false;
$hasCompany = false;
$hasType = false;
$mergeVars = $api->listMergeVars($variables["mailchimp_list_id"]);
if ($api->errorCode) {
unset($variables["mailchimp_list_id"]);
$this->updateErrorMessage = "Unable to change the MailChimp list id: " . $api->errorMessage . " (" . $api->errorCode . ")";
return $variables;
}
//end if
$req = array();
foreach ($mergeVars as $mergeVar) {
switch ($mergeVar["tag"]) {
case "UUID":
$hasUuid = true;
break;
case "COMPANY":
$hasCompany = true;
break;
case "TYPE":
$hasType = true;
break;
}
//end switch
}
//end foreach
/**
* If it doesn't have a uuid field, create it.
*/
if (!$hasUuid) {
$req = array("req" => true, "public" => false, "field_type" => "text");
$api->listMergeVarAdd($variables["mailchimp_list_id"], "UUID", "phpBMS unique user id", $req);
//.........这里部分代码省略.........