当前位置: 首页>>代码示例>>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;未经允许,请勿转载。