本文整理汇总了PHP中_wp_http_get_object函数的典型用法代码示例。如果您正苦于以下问题:PHP _wp_http_get_object函数的具体用法?PHP _wp_http_get_object怎么用?PHP _wp_http_get_object使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_wp_http_get_object函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeRequest
protected function makeRequest($url, $params, $ch = null)
{
$http = _wp_http_get_object();
$args = array();
$args['method'] = 'POST';
$args['body'] = http_build_query($params, null, '&');
// disable the 'Expect: 100-continue' behaviour. This causes CURL to wait
// for 2 seconds if the server does not support this header.
$opts = self::$CURL_OPTS;
if (isset($opts[CURLOPT_HTTPHEADER])) {
$existing_headers = $opts[CURLOPT_HTTPHEADER];
$existing_headers[] = 'Expect:';
$opts[CURLOPT_HTTPHEADER] = $existing_headers;
} else {
$opts[CURLOPT_HTTPHEADER] = array('Expect:');
}
$args['headers'] = $opts[CURLOPT_HTTPHEADER];
$args['sslverify'] = false;
$args['timeout'] = $opts[CURLOPT_CONNECTTIMEOUT] * 1000;
$result = $http->request($url, $args);
if (is_wp_error($result)) {
throw new SpFacebookApiException(array('error_code' => (int) $result->get_error_code(), 'error' => array('message' => $result->get_error_message(), 'type' => 'WP_Error')));
}
return $result['body'];
}
示例2: test_normalize_cookies_scalar_values
/**
* @ticket 37768
*/
public function test_normalize_cookies_scalar_values()
{
$http = _wp_http_get_object();
$cookies = array('x' => 'foo', 'y' => 2, 'z' => 0.45, 'foo' => array('bar'));
$cookie_jar = $http->normalize_cookies(array('x' => 'foo', 'y' => 2, 'z' => 0.45, 'foo' => array('bar')));
$this->assertInstanceOf('Requests_Cookie_Jar', $cookie_jar);
foreach (array_keys($cookies) as $cookie) {
if ('foo' === $cookie) {
$this->assertFalse(isset($cookie_jar[$cookie]));
} else {
$this->assertInstanceOf('Requests_Cookie', $cookie_jar[$cookie]);
}
}
}
示例3: sparkpostSend
function sparkpostSend()
{
$this->edebug('Preparing request data');
$data = array('method' => 'POST', 'timeout' => 15, 'headers' => $this->get_request_headers(), 'body' => json_encode($this->get_request_body()));
$http = apply_filters('wpsp_get_http_lib', _wp_http_get_object());
$this->edebug(sprintf('Request headers: %s', print_r($this->get_request_headers(true), true)));
$this->edebug(sprintf('Request body: %s', $data['body']));
$this->edebug(sprintf('Making HTTP POST request to %s', $this->endpoint));
do_action('wpsp_before_send', $this->endpoint, $data);
$result = $http->request($this->endpoint, $data);
do_action('wpsp_after_send', $result);
$this->edebug('Response received');
$result = apply_filters('wpsp_handle_response', $result);
if (is_bool($result)) {
// it means, response been already processed by the hooked filter. so just return the value.
$this->edebug('Skipping response processing');
return $result;
} else {
return $this->handle_response($result);
}
}
示例4: wp_remote_head
/**
* Retrieve the raw response from the HTTP request using the HEAD method.
*
* @see wp_remote_request() For more information on the response array format.
*
* @since 2.7.0
*
* @param string $url Site URL to retrieve.
* @param array $args Optional. Override the defaults.
* @return WP_Error|array The response or WP_Error on failure.
*/
function wp_remote_head($url, $args = array())
{
$objFetchSite = _wp_http_get_object();
return $objFetchSite->head($url, $args);
}
示例5: upgrader_extension_pre_download_filter
function upgrader_extension_pre_download_filter($reply, $package, $upgrader)
{
global $wp_filesystem;
$option = get_option($this->option_key);
$current_theme_name = "";
if (isset($upgrader->skin->theme_info)) {
$current_theme_name = $upgrader->skin->theme_info->get('Name');
} else {
return false;
}
if (is_array($option) && isset($option['data']['extensions']) && is_array($option['data']['extensions'])) {
foreach ($option['data']['extensions'] as $key => $response) {
//find extensions in updater
if ($key == $current_theme_name && isset($response['rw_extension']) && $response['rw_extension'] == true) {
$upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/';
if (is_array($package)) {
$package = $package[0];
}
$http = _wp_http_get_object();
$http_response = $http->get($package);
if ($http_response['response']['code'] == '500') {
return false;
}
$fname = $wp_filesystem->wp_content_dir() . basename($package);
$file = fopen($fname, 'w+');
// Create a new file, or overwrite the existing one.
fwrite($file, $http_response['body']);
fclose($file);
return $fname;
}
}
}
return false;
}
示例6: display_feedfinder
//.........这里部分代码省略.........
?>
</div>
<div>
<h3>Feed Information</h3>
<ul>
<li><strong>Homepage:</strong> <a href="<?php
echo $feed_link;
?>
"><?php
echo is_null($feed_title) ? '<em>Unknown</em>' : $feed_title;
?>
</a></li>
<li><strong>Feed URL:</strong> <a title="<?php
echo esc_html($f);
?>
" href="<?php
echo esc_html($f);
?>
"><?php
echo esc_html(feedwordpress_display_url($f, 40, 10));
?>
</a> (<a title="Check feed <<?php
echo esc_html($f);
?>
> for validity" href="http://feedvalidator.org/check.cgi?url=<?php
echo urlencode($f);
?>
">validate</a>)</li>
<li><strong>Encoding:</strong> <?php
echo isset($rss->encoding) ? esc_html($rss->encoding) : "<em>Unknown</em>";
?>
</li>
<li><strong>Description:</strong> <?php
echo isset($rss->channel['description']) ? esc_html($rss->channel['description']) : "<em>Unknown</em>";
?>
</li>
</ul>
<?php
$this->display_authentication_credentials_box(array('username' => $username, 'password' => $password, 'method' => $auth));
?>
<?php
do_action('feedwordpress_feedfinder_form', $f, $post, $link, $this->for_feed_settings());
?>
<div class="submit"><input type="submit" class="button-primary" name="Use" value="« Use this feed" />
<input type="submit" class="button" name="Cancel" value="× Cancel" /></div>
</div>
</div>
</fieldset>
</div> <!-- class="inside" -->
</form>
<?php
unset($link);
unset($post);
}
} else {
foreach ($finder as $url => $ff) {
$url = esc_html($url);
print "<h3>Searched for feeds at {$url}</h3>\n";
print "<p><strong>" . __('Error') . ":</strong> " . __("FeedWordPress couldn't find any feeds at") . ' <code><a href="' . htmlspecialchars($lookup) . '">' . htmlspecialchars($lookup) . '</a></code>';
print ". " . __('Try another URL') . ".</p>";
// Diagnostics
print "<div class=\"updated\" style=\"margin-left: 3.0em; margin-right: 3.0em;\">\n";
print "<h3>" . __('Diagnostic information') . "</h3>\n";
if (!is_null($ff->error()) and strlen($ff->error()) > 0) {
print "<h4>" . __('HTTP request failure') . "</h4>\n";
print "<p>" . $ff->error() . "</p>\n";
} else {
print "<h4>" . __('HTTP request completed') . "</h4>\n";
print "<p><strong>Status " . $ff->status() . ":</strong> " . $this->HTTPStatusMessages[(int) $ff->status()] . "</p>\n";
}
// Do some more diagnostics if the API for it is available.
if (function_exists('_wp_http_get_object')) {
$httpObject = _wp_http_get_object();
if (is_callable(array($httpObject, '_getTransport'))) {
$transports = $httpObject->_getTransport();
print "<h4>" . __('HTTP Transports available') . ":</h4>\n";
print "<ol>\n";
print "<li>" . implode("</li>\n<li>", array_map('get_class', $transports)) . "</li>\n";
print "</ol>\n";
} elseif (is_callable(array($httpObject, '_get_first_available_transport'))) {
$transport = $httpObject->_get_first_available_transport(array(), $url);
print "<h4>" . __("HTTP Transport") . ":</h4>\n";
print "<ol>\n";
print "<li>" . FeedWordPress::val($transport) . "</li>\n";
print "</ol>\n";
}
print "</div>\n";
}
}
}
if (!$feedSwitch) {
$this->display_alt_feed_box($lookup, true);
}
?>
</div> <!-- class="wrap" -->
<?php
return false;
// Don't continue
}
示例7: GAPI
function GAPI($username, $password)
{
$this->username = $username;
$this->password = $password;
$this->request = _wp_http_get_object();
}
示例8: server_info
/**
* How does the site communicate with Facebook?
*
* @since 1.1.6
*
* @return void
*/
public static function server_info()
{
echo '<section id="debug-server"><header><h3>' . esc_html(__('Server configuration', 'facebook')) . '</h3></header><table><thead><th>' . esc_html(__('Feature', 'facebook')) . '</th><th>' . esc_html(_x('Info', 'Information', 'facebook')) . '</th></thead><tbody>';
// PHP version
echo '<tr><th>' . esc_html(sprintf(_x('%s version', 'software version', 'facebook'), 'PHP')) . '</th><td>';
// PHP > 5.2.7
if (defined('PHP_MAJOR_VERSION') && defined('PHP_MINOR_VERSION') && defined('PHP_RELEASE_VERSION')) {
echo esc_html(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION);
} else {
esc_html(phpversion());
}
echo '</td></tr>';
// WordPress version
echo '<tr><th>' . esc_html(sprintf(_x('%s version', 'software version', 'facebook'), 'WordPress')) . '</th><td>' . esc_html(get_bloginfo('version')) . '</td></tr>';
if (isset($_SERVER['SERVER_SOFTWARE'])) {
echo '<tr><th>' . esc_html(__('Server software', 'facebook')) . '</th><td>' . esc_html($_SERVER['SERVER_SOFTWARE']) . '</td></tr>';
}
// WP_HTTP connection for SSL
echo '<tr id="debug-server-http">';
echo '<th>' . sprintf(esc_html(_x('%s connection method', 'server-to-server connection', 'facebook')), '<a href="http://codex.wordpress.org/HTTP_API">WP_HTTP</a>') . '</th><td>';
$http_obj = _wp_http_get_object();
$http_transport = $http_obj->_get_first_available_transport(array('ssl' => true));
if (is_string($http_transport) && strlen($http_transport) > 8) {
$http_transport = strtolower(substr($http_transport, 8));
if ($http_transport === 'curl') {
echo '<a href="http://php.net/manual/book.curl.php">cURL</a>';
$curl_version = curl_version();
if (isset($curl_version['version'])) {
echo ' ' . esc_html($curl_version['version']);
}
if (isset($curl_version['ssl_version'])) {
echo '; ';
$ssl_version = $curl_version['ssl_version'];
if (strlen($curl_version['ssl_version']) > 8 && substr_compare($ssl_version, 'OpenSSL/', 0, 8) === 0) {
echo '<a href="http://openssl.org/">OpenSSL</a>/' . esc_html(substr($ssl_version, 8));
} else {
echo esc_html($ssl_version);
}
unset($ssl_version);
}
unset($curl_version);
} else {
if ($http_transport === 'streams') {
echo '<a href="http://www.php.net/manual/book.stream.php">Stream</a>';
} else {
if ($http_transport === 'fsockopen') {
echo '<a href="http://php.net/manual/function.fsockopen.php">fsockopen</a>';
} else {
echo $http_transport;
}
}
}
} else {
echo __('none available', 'facebook');
}
echo '</td></tr>';
unset($http_transport);
unset($http_obj);
echo '</table></section>';
}
示例9: _remote_delete
function _remote_delete($request_url, $args = array())
{
// fetch
$objFetchSite = _wp_http_get_object();
$defaults = array('method' => 'DELETE');
$r = wp_parse_args($args, $defaults);
// log
mgm_log($request_url, __FUNCTION__);
// log
mgm_log($args, __FUNCTION__);
// request
$request = $objFetchSite->request($request_url, $r);
// log
mgm_log($request, __FUNCTION__);
// validate, 200 and 302, WP permalink cacuses 302 Found/Temp Redirect often
if (is_wp_error($request)) {
return $request->get_error_message();
}
// return
return wp_remote_retrieve_body($request);
}
示例10: request
public function request($url, $method = 'GET')
{
$this->method = strtoupper($method);
$args = array();
foreach (get_object_vars($this) as $prop => $val) {
$args[str_replace('_', '-', $prop)] = $this->{$prop};
}
$start_time = microtime(true);
$response = _wp_http_get_object()->request($url, $args);
if ($response instanceof WP_Error) {
return $response;
}
$response = (array) $response;
$response['_start_time'] = $start_time;
return new Response($response);
}
示例11: skip_curl
/**
* Maybe skip the cURL transport for this request
* @access private
* @return boolean
*/
private function skip_curl()
{
// if we already skipped curl, don't bother
if ($this->skipped_curl === true) {
return false;
}
$transport_used = _wp_http_get_object()->_get_first_available_transport($this->args, $this->url);
if (strtolower($transport_used) !== 'wp_http_curl') {
return false;
}
add_filter('http_api_transports', array($this, 'disable_curl_transport'));
$this->skipped_curl = true;
return true;
}
示例12: api
/**
* Send a request to the Graph API.
* @param $path
* @param $params
* @param $method
* @return The API response or a WP_Error object
*/
function api($path, $params = null, $method = 'GET')
{
$http = _wp_http_get_object();
$url = 'https://graph.facebook.com/' . trim($path, '/');
$args = array();
$args['method'] = $method;
if ($method == 'POST') {
$args['body'] = http_build_query($params, null, '&');
} else {
if ($params) {
$url .= '/?' . http_build_query($params, null, '&');
}
}
// disable the 'Expect: 100-continue' behaviour. This causes CURL to wait
// for 2 seconds if the server does not support this header.
$opts = array(CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 60, CURLOPT_USERAGENT => __CLASS__);
if (isset($opts[CURLOPT_HTTPHEADER])) {
$existing_headers = $opts[CURLOPT_HTTPHEADER];
$existing_headers[] = 'Expect:';
$opts[CURLOPT_HTTPHEADER] = $existing_headers;
} else {
$opts[CURLOPT_HTTPHEADER] = array('Expect:');
}
$args['headers'] = $opts[CURLOPT_HTTPHEADER];
$args['sslverify'] = false;
$args['timeout'] = $opts[CURLOPT_CONNECTTIMEOUT] * 1000;
// echo "{$url}\n";
$result = $http->request($url, $args);
if (!is_wp_error($result)) {
return json_decode($result['body']);
} else {
error_log($result->get_error_message());
return false;
}
}
示例13: get_bitly_link
function get_bitly_link($post_id)
{
$post = get_page($post_id);
if (!$post->ID) {
return false;
}
$permalink = $this->get_permalink($post->ID);
if (!($login = $this->setting('bitly_login'))) {
return $permalink;
}
if (!($apikey = $this->setting('bitly_apikey'))) {
return $permalink;
}
if ($post->post_status == 'publish') {
$response = _wp_http_get_object()->request('https://api-ssl.bitly.com/v3/shorten?' . http_build_query(array('login' => $login, 'apikey' => $apikey, 'longUrl' => $this->get_permalink($post->ID), 'format' => 'json', 'sslverify' => false)), array('method' => 'GET'));
if (is_wp_error($response)) {
SharePress::log('Bit.ly issue: ' . json_encode($response), 'ERROR');
return $permalink;
} else {
$result = json_decode($response['body']);
if ($result->status_code == 200) {
return $result->data->url;
} else {
SharePress::log('Bit.ly issue: ' . json_encode($response), 'ERROR');
return $permalink;
}
}
} else {
return $permalink;
}
}
示例14: request
/**
* Make a request using the WP http API
*
* @since 0.2.2
*
* @param string $uri URI to make request to
* @param string $request_type Type of request. Defaults to 'get'
*
* @return mixed Return of the request.
*/
public function request($uri, $request_type = 'get')
{
$http = _wp_http_get_object();
$response = $http->{$request_type}($uri, $this->args);
if (is_wp_error($response)) {
throw new Exception($response->get_error_code() . ': ' . $response->get_error_message());
}
$code = $response['response']['code'];
$success = $code >= 200 && $code < 300;
if (!$success) {
// Use Requests error handling.
$exception = Requests_Exception_HTTP::get_class($code);
throw new $exception(null, $this);
}
return $response;
}
示例15: on_init
function on_init()
{
$this->boot_loader->pass_checkpoint('hook:init');
$http = _wp_http_get_object();
//force collect of transports
global $wp_version;
if (version_compare($wp_version, "2.8", '<')) {
wp_deregister_script('jquery');
wp_deregister_script('jquery-ui-core');
wp_deregister_script('jquery-ui-tabs');
wp_deregister_script('jquery-ui-sortable');
wp_deregister_script('jquery-ui-draggable');
wp_deregister_script('jquery-ui-resizable');
wp_deregister_script('jquery-ui-dialog');
wp_register_script('jquery', WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/js/wordpress-2.7/jquery.js', false, '1.3.2');
wp_register_script('jquery-ui-core', WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/js/wordpress-2.7/ui.core.js', array('jquery'), '1.7.1');
wp_register_script('jquery-ui-tabs', WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/js/wordpress-2.7/ui.tabs.js', array('jquery-ui-core'), '1.7.1');
wp_register_script('jquery-ui-sortable', WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/js/wordpress-2.7/ui.sortable.js', array('jquery-ui-core'), '1.7.1');
wp_register_script('jquery-ui-draggable', WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/js/wordpress-2.7/ui.draggable.js', array('jquery-ui-core'), '1.7.1');
wp_register_script('jquery-ui-resizable', WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/js/wordpress-2.7/ui.resizable.js', array('jquery-ui-core'), '1.7.1');
wp_register_script('jquery-ui-dialog', WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/js/wordpress-2.7/ui.dialog.js', array('jquery-ui-resizable', 'jquery-ui-draggable'), '1.7.1');
}
}