本文整理匯總了PHP中IXR_Client::isError方法的典型用法代碼示例。如果您正苦於以下問題:PHP IXR_Client::isError方法的具體用法?PHP IXR_Client::isError怎麽用?PHP IXR_Client::isError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類IXR_Client
的用法示例。
在下文中一共展示了IXR_Client::isError方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: purge
/**
* Purges remote files
*
* @param array $files
* @param array $results
* @return boolean
*/
function purge($files, &$results)
{
if (empty($this->_config['apiid'])) {
$results = $this->_get_results($files, W3TC_CDN_RESULT_HALT, 'Empty API ID.');
return false;
}
if (empty($this->_config['apikey'])) {
$results = $this->_get_results($files, W3TC_CDN_RESULT_HALT, 'Empty API key.');
return false;
}
if ($this->_sha256('test') === false) {
$results = $this->_get_results($files, W3TC_CDN_RESULT_HALT, "hash() or mhash() function doesn't exists.");
return false;
}
if (!class_exists('IXR_Client')) {
require_once ABSPATH . WPINC . '/class-IXR.php';
}
if (function_exists('date_default_timezone_set')) {
$timezone = date_default_timezone_get();
date_default_timezone_set(W3TC_CDN_MIRROR_NETDNA_TZ);
}
$date = date('c');
$auth_string = sprintf('%s:%s:purge', $date, $this->_config['apikey']);
$auth_key = $this->_sha256($auth_string);
$client = new IXR_Client(W3TC_CDN_MIRROR_NETDNA_URL);
$client->timeout = 30;
$results = array();
foreach ($files as $local_path => $remote_path) {
$url = $this->format_url($remote_path);
$client->query('cache.purge', $this->_config['apiid'], $auth_key, $date, $url);
if (!$client->isError()) {
$val = $client->getResponse();
if ($val) {
$results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_OK, 'OK');
} else {
$results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_ERROR, 'Unable to purge.');
}
} else {
$results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_HALT, sprintf('Unable to purge (%s).', $client->getErrorMessage()));
}
}
if (function_exists('date_default_timezone_set')) {
date_default_timezone_set($timezone);
}
return !$this->_is_error($results);
}
示例2: stats_get_blog_id
function stats_get_blog_id($api_key)
{
$options = stats_get_options();
require_once ABSPATH . WPINC . '/class-IXR.php';
$client = new IXR_Client(STATS_XMLRPC_SERVER);
extract(parse_url(get_option('home')));
$path = rtrim($path, '/');
if (empty($path)) {
$path = '/';
}
$client->query('wpStats.get_blog_id', $api_key, stats_get_blog());
if ($client->isError()) {
if ($client->getErrorCode() == -32300) {
$options['error'] = __('Your blog was unable to connect to WordPress.com. Please ask your host for help. (' . $client->getErrorMessage() . ')', 'stats');
} else {
$options['error'] = $client->getErrorMessage();
}
stats_set_options($options);
return false;
} else {
$options['error'] = false;
}
$response = $client->getResponse();
$blog_id = isset($response['blog_id']) ? (int) $response['blog_id'] : false;
$options['host'] = $host;
$options['path'] = $path;
$options['blog_id'] = $blog_id;
stats_set_options($options);
stats_set_api_key($api_key);
return $blog_id;
}