本文整理汇总了PHP中Jetpack_Client::remote_request方法的典型用法代码示例。如果您正苦于以下问题:PHP Jetpack_Client::remote_request方法的具体用法?PHP Jetpack_Client::remote_request怎么用?PHP Jetpack_Client::remote_request使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jetpack_Client
的用法示例。
在下文中一共展示了Jetpack_Client::remote_request方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: query
function query()
{
$args = func_get_args();
$method = array_shift($args);
$request = new IXR_Request($method, $args);
$xml = trim($request->getXml());
$response = Jetpack_Client::remote_request($this->jetpack_args, $xml);
if (is_wp_error($response)) {
$this->error = new IXR_Error(-10520, sprintf('Jetpack: [%s] %s', $response->get_error_code(), $response->get_error_message()));
return false;
}
if (!$response) {
$this->error = new IXR_Error(-10520, 'Jetpack: Unknown Error');
return false;
}
if (200 != wp_remote_retrieve_response_code($response)) {
$this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
return false;
}
$content = wp_remote_retrieve_body($response);
// Now parse what we've got back
$this->message = new IXR_Message($content);
if (!$this->message->parse()) {
// XML error
$this->error = new IXR_Error(-32700, 'parse error. not well formed');
return false;
}
// Is the message a fault?
if ($this->message->messageType == 'fault') {
$this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
return false;
}
// Message must be OK
return true;
}
示例2: stats_get_remote_csv
function stats_get_remote_csv($url)
{
$method = 'GET';
$timeout = 90;
$user_id = JETPACK_MASTER_USER;
$get = Jetpack_Client::remote_request(compact('url', 'method', 'timeout', 'user_id'));
$get_code = wp_remote_retrieve_response_code($get);
if (is_wp_error($get) || 2 != intval($get_code / 100) && 304 != $get_code || empty($get['body'])) {
return array();
// @todo: return an error?
} else {
return stats_str_getcsv($get['body']);
}
}
示例3: wpcom_json_api_request_as_blog
/**
* Query the WordPress.com REST API using the blog token
*
* @param string $path
* @param string $version
* @param array $args
* @param string $body
* @return array|WP_Error $response Data.
*/
static function wpcom_json_api_request_as_blog($path, $version = self::WPCOM_JSON_API_VERSION, $args = array(), $body = null)
{
$filtered_args = array_intersect_key($args, array('method' => 'string', 'timeout' => 'int', 'redirection' => 'int'));
/**
* Determines whether Jetpack can send outbound https requests to the WPCOM api.
*
* @since 3.6.0
*
* @param bool $proto Defaults to true.
*/
$proto = apply_filters('jetpack_can_make_outbound_https', true) ? 'https' : 'http';
// unprecedingslashit
$_path = preg_replace('/^\\//', '', $path);
// Use GET by default whereas `remote_request` uses POST
if (isset($filtered_args['method']) && strtoupper($filtered_args['method'] === 'POST')) {
$request_method = 'POST';
} else {
$request_method = 'GET';
}
$validated_args = array_merge($filtered_args, array('url' => sprintf('%s://%s/rest/v%s/%s', $proto, JETPACK__WPCOM_JSON_API_HOST, $version, $_path), 'blog_id' => (int) Jetpack_Options::get_option('id'), 'method' => $request_method));
return Jetpack_Client::remote_request($validated_args, $body);
}