本文整理汇总了PHP中MCAPI::ping方法的典型用法代码示例。如果您正苦于以下问题:PHP MCAPI::ping方法的具体用法?PHP MCAPI::ping怎么用?PHP MCAPI::ping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MCAPI
的用法示例。
在下文中一共展示了MCAPI::ping方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MCAPI
function validate_cfg()
{
$OSCOM_Db = Registry::get('Db');
$this->valid_cfg = false;
if (empty($this->apikey)) {
$this->complain('You have not entered your API key. Please read the installation instructions.');
return;
}
if (!$this->key_valid) {
$GLOBALS["mc_api_key"] = $this->apikey;
$api = new MCAPI('notused', 'notused');
$res = $api->ping();
if ($api->errorMessage != '') {
$this->complain('Server said: "' . $api->errorMessage . '". Your API key is likely invalid. Please read the installation instructions.');
return;
} else {
$this->key_valid = true;
$OSCOM_Db->save('configuration', ['configuration_value' => 'true'], ['configuration_key' => 'MODULE_HEADER_TAGS_MAILCHIMP_360_KEY_VALID']);
if (empty($this->store_id)) {
$this->store_id = md5(uniqid(rand(), true));
$OSCOM_Db->save('configuration', ['configuration_value' => $this->store_id], ['configuration_key' => 'MODULE_HEADER_TAGS_MAILCHIMP_360_STORE_ID']);
}
}
}
if (empty($this->store_id)) {
$this->complain('Your Store ID has not been set. This is not good. Contact support.');
} else {
$this->valid_cfg = true;
}
}
示例2: MCAPI
function validate_cfg()
{
$this->valid_cfg = false;
if (empty($this->apikey)) {
$this->complain('You have not entered your API key. Please read the installation instructions.');
return;
}
if (!$this->key_valid) {
$GLOBALS["mc_api_key"] = $this->apikey;
$api = new MCAPI('notused', 'notused');
$res = $api->ping();
if ($api->errorMessage != '') {
$this->complain('Server said: "' . $api->errorMessage . '". Your API key is likely invalid. Please read the installation instructions.');
return;
} else {
$this->key_valid = true;
tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = 'true' where configuration_key = 'MODULE_HEADER_TAGS_MAILCHIMP_360_KEY_VALID'");
if (empty($this->store_id)) {
$this->store_id = md5(uniqid(rand(), true));
tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $this->store_id . "' where configuration_key = 'MODULE_HEADER_TAGS_MAILCHIMP_360_STORE_ID'");
}
}
}
if (empty($this->store_id)) {
$this->complain('Your Store ID has not been set. This is not good. Contact support.');
} else {
$this->valid_cfg = true;
}
}
示例3: MCauth
function MCauth()
{
if (!isset($_SESSION['MCping'])) {
jimport('joomla.html.parameter');
jimport('joomla.application.component.helper');
$params =& JComponentHelper::getParams('com_joomailermailchimpintegration');
$paramsPrefix = version_compare(JVERSION, '1.6.0', 'ge') ? 'params.' : '';
$MCapi = $params->get($paramsPrefix . 'MCapi');
$MC = new MCAPI($MCapi);
$ping = $MC->ping();
$_SESSION['MCping'] = $ping;
} else {
$ping = $_SESSION['MCping'];
}
return $ping;
}
示例4: MCAPI
function validate_mailchimp_key($key)
{
require_once PREMISE_LIB_DIR . 'mailchimp_api/MCAPI.class.php';
$mailchimp = new MCAPI($key);
if (!$mailchimp->ping()) {
return array('error' => __('Invalid MailChimp API key.', 'premise'));
}
return true;
}
示例5: dirname
function tfuse_ajax_newsletter_save_mailchimp_api_key()
{
#MailChimp
tf_can_ajax();
require_once dirname(__FILE__) . '/library/MCAPI.class.php';
$api_key = $this->request->POST('api_key');
$api = new MCAPI($api_key);
$api->ping();
if ($api->errorCode) {
tfjecho(array('status' => -1, 'message' => __('API key is invalid.', 'tfuse')));
} else {
$this->model->set_mc_key($api_key);
tfjecho(array('status' => 1));
}
die;
}
示例6: 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);
//.........这里部分代码省略.........
示例7: getMailChimpTimestamp
public function getMailChimpTimestamp()
{
$api = new MCAPI($this->apikey);
$retval = $api->ping();
if ($api->errorCode) {
SS_Log::log("Unable to load lists()! Error Code = " . $api->errorCode . " Error Msg = " . $api->errorMessage, SS_Log::ERR);
return false;
} else {
return gmdate('Y-m-d H:i:s', strtotime($retval['headers']['Date']));
}
}