當前位置: 首頁>>代碼示例>>PHP>>正文


PHP MCAPI::listMergeVarAdd方法代碼示例

本文整理匯總了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);
//.........這裏部分代碼省略.........
開發者ID:Jacquesvw,項目名稱:phpBMS,代碼行數:101,代碼來源:adminsettings.php


注:本文中的MCAPI::listMergeVarAdd方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。