当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_remote_retrieve_response_code函数代码示例

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


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

示例1: plugin_information

 /**
  * Sends and receives data to and from the server API
  *
  * @access public
  * @since  1.0.0
  * @return object $response
  */
 public function plugin_information($args)
 {
     $target_url = $this->create_upgrade_api_url($args);
     $apisslverify = get_option('mainwp_api_sslVerifyCertificate') === false || get_option('mainwp_api_sslVerifyCertificate') == 1 ? 1 : 0;
     $request = wp_remote_get($target_url, array('timeout' => 50, 'sslverify' => $apisslverify));
     //      $request = wp_remote_post( MainWP_Api_Manager::instance()->getUpgradeUrl() . 'wc-api/upgrade-api/', array('body' => $args) );
     if (is_wp_error($request) || wp_remote_retrieve_response_code($request) != 200) {
         return false;
     }
     $response = unserialize(wp_remote_retrieve_body($request));
     /**
      * For debugging errors from the API
      * For errors like: unserialize(): Error at offset 0 of 170 bytes
      * Comment out $response above first
      */
     // $response = wp_remote_retrieve_body( $request );
     // print_r($response); exit;
     if (is_object($response)) {
         if (isset($response->package)) {
             $response->package = apply_filters('mainwp_api_manager_upgrade_url', $response->package);
         }
         return $response;
     } else {
         return false;
     }
 }
开发者ID:reeslo,项目名称:mainwp,代码行数:33,代码来源:class-mainwp-api-manager-plugin-update.php

示例2: test_get_issuers

 public function test_get_issuers()
 {
     add_filter('pre_http_request', array($this, 'pre_http_request'), 10, 3);
     $url = 'https://www.targetpay.com/ideal/getissuers.php?format=xml';
     $response = wp_remote_get($url);
     $this->assertEquals(200, wp_remote_retrieve_response_code($response));
 }
开发者ID:wp-pay-gateways,项目名称:targetpay,代码行数:7,代码来源:RemoteGetTest.php

示例3: __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

示例4: 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

示例5: 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

示例6: fetch_feed

 function fetch_feed($username, $slice = 8)
 {
     $barcelona_remote_url = esc_url('http://instagram.com/' . trim(strtolower($username)));
     $barcelona_transient_key = 'barcelona_instagram_feed_' . sanitize_title_with_dashes($username);
     $slice = absint($slice);
     if (false === ($barcelona_result_data = get_transient($barcelona_transient_key))) {
         $barcelona_remote = wp_remote_get($barcelona_remote_url);
         if (is_wp_error($barcelona_remote) || 200 != wp_remote_retrieve_response_code($barcelona_remote)) {
             return new WP_Error('not-connected', esc_html__('Unable to communicate with Instagram.', 'barcelona'));
         }
         preg_match('#window\\.\\_sharedData\\s\\=\\s(.*?)\\;\\<\\/script\\>#', $barcelona_remote['body'], $barcelona_match);
         if (!empty($barcelona_match)) {
             $barcelona_data = json_decode(end($barcelona_match), true);
             if (is_array($barcelona_data) && isset($barcelona_data['entry_data']['ProfilePage'][0]['user']['media']['nodes'])) {
                 $barcelona_result_data = $barcelona_data['entry_data']['ProfilePage'][0]['user']['media']['nodes'];
             }
         }
         if (is_array($barcelona_result_data)) {
             set_transient($barcelona_transient_key, $barcelona_result_data, 60 * 60 * 2);
         }
     }
     if (empty($barcelona_result_data)) {
         return new WP_Error('no-images', esc_html__('Instagram did not return any images.', 'barcelona'));
     }
     return array_slice($barcelona_result_data, 0, $slice);
 }
开发者ID:yalmaa,项目名称:little-magazine,代码行数:26,代码来源:barcelona-instagram-feed.php

示例7: _manually_load_plugin

function _manually_load_plugin()
{
    $host = getenv('ES_HOST');
    $host = preg_replace('/(^https:\\/\\/|^http:\\/\\/)/is', '', $host);
    $port = getenv('ES_PORT');
    if (empty($host)) {
        $host = 'localhost';
    }
    if (empty($port)) {
        $port = 9200;
    }
    define('ES_HOST', $host);
    define('ES_PORT', $port);
    require dirname(dirname(__FILE__)) . '/wp-elasticsearch.php';
    $tries = 5;
    $sleep = 3;
    do {
        $response = wp_remote_get(esc_url(ES_HOST) . ':' . ES_PORT);
        if (200 == wp_remote_retrieve_response_code($response)) {
            // Looks good!
            break;
        } else {
            printf("\nInvalid response from ES, sleeping %d seconds and trying again...\n", intval($sleep));
            sleep($sleep);
        }
    } while (--$tries);
    if (200 != wp_remote_retrieve_response_code($response)) {
        exit('Could not connect to Elasticsearch server.');
    }
}
开发者ID:horike37,项目名称:wp-elasticsearch,代码行数:30,代码来源:bootstrap.php

示例8: 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

示例9: glyphs_get_typekit_fonts

 /**
  * Get info about the fonts available in the current kit
  *
  * @param  string        $kit_id    The id of the kit.
  * @param  bool          $force     True to ignore cached info.
  * @return array|bool               An array of font information, or false if the kit ID is invalid.
  */
 function glyphs_get_typekit_fonts($kit_id = null, $force = false)
 {
     if (null === $kit_id) {
         $kit_id = get_theme_mod('typekit-id', false);
     }
     if (!$kit_id) {
         return false;
     }
     // Get cached font info
     $fonts = get_transient('glyphs-typekit-fonts');
     if (empty($fonts) || true === $force) {
         $fonts = array();
         // Look up the font kit
         $response = wp_remote_get('https://typekit.com/api/v1/json/kits/' . $kit_id . '/published');
         $response_code = wp_remote_retrieve_response_code($response);
         $response_body = json_decode(wp_remote_retrieve_body($response));
         // If the font kit returns a valid response, parse the font info
         if (200 === (int) $response_code && is_object($response_body) && isset($response_body->kit) && isset($response_body->kit->families) && is_array($response_body->kit->families)) {
             foreach ($response_body->kit->families as $family) {
                 $fonts[sanitize_title_with_dashes($family->slug)] = array('label' => wp_strip_all_tags($family->name), 'stack' => isset($family->css_stack) ? wp_strip_all_tags($family->css_stack) : '');
             }
         }
         // Cache the font info
         set_transient('glyphs-typekit-fonts', $fonts, DAY_IN_SECONDS);
     }
     return $fonts;
 }
开发者ID:andrewkhunn,项目名称:lancero,代码行数:34,代码来源:glyphs-global.php

示例10: 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;
 }
开发者ID:StefanBonilla,项目名称:CoupSoup,代码行数:35,代码来源:class.jetpack-ixr-client.php

示例11: uploadFile

 static function uploadFile($file_url, $path, $file_name)
 {
     $file_name = sanitize_file_name($file_name);
     $full_file_name = $path . DIRECTORY_SEPARATOR . $file_name;
     //Local name
     $response = wp_remote_get($file_url, array('timeout' => 10 * 60 * 60, 'stream' => true, 'filename' => $full_file_name));
     if (is_wp_error($response)) {
         @unlink($full_file_name);
         throw new Exception('Error: ' . $response->get_error_message());
     }
     if (200 != wp_remote_retrieve_response_code($response)) {
         @unlink($full_file_name);
         throw new Exception('Error 404: ' . trim(wp_remote_retrieve_response_message($response)));
     }
     if (substr($file_name, -12) == ".phpfile.txt") {
         $new_file_name = substr($file_name, 0, -12) . ".php";
         $new_file_name = $path . DIRECTORY_SEPARATOR . $new_file_name;
         $moved = @rename($full_file_name, $new_file_name);
         if ($moved) {
             return array('path' => $new_file_name);
         } else {
             @unlink($full_file_name);
             throw new Exception('Error: Copy file.');
         }
     }
     return array('path' => $full_file_name);
 }
开发者ID:HasClass0,项目名称:mainwp-child,代码行数:27,代码来源:MainWPHelper.class.php

示例12: test_head_404

 function test_head_404()
 {
     $url = 'http://asdftestblog1.files.wordpress.com/2007/09/awefasdfawef.jpg';
     $headers = wp_remote_head($url);
     $this->assertInternalType('array', $headers, "Reply wasn't array.");
     $this->assertEquals('404', wp_remote_retrieve_response_code($headers));
 }
开发者ID:boonebgorges,项目名称:wp,代码行数:7,代码来源:functions.php

示例13: minify

 /**
  * Minify JavaScript using Google's Closure Compiler
  */
 public static function minify($js_code, $args = array())
 {
     $js_hash = md5($js_code);
     $js_cache = get_option('_youxi_minjs_cache', array());
     /* Check first if we have the JS string in cache */
     if (is_array($js_cache) && isset($js_cache[$js_hash]) && is_string($js_cache[$js_hash])) {
         return $js_cache[$js_hash];
     }
     // Default request data
     $request_data = array('output_info' => array('compiled_code', 'warnings', 'errors', 'statistics'), 'output_format' => 'json');
     $request_data = array_merge($request_data, $args, compact('js_code'));
     // Process the request body manually to make same named parameters possible
     $body = http_build_query($request_data, null, '&');
     $body = preg_replace('/output_info%5B\\d+%5D=/', 'output_info=', $body);
     // Initiate request
     $response = wp_remote_post(CLOSURE_COMPILER_URL, array('sslverify' => false, 'timeout' => 10, 'headers' => array('Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset')), 'body' => $body));
     // Check if the request was successful
     if (!is_wp_error($response) && 200 == wp_remote_retrieve_response_code($response)) {
         $response_body = wp_remote_retrieve_body($response);
         $response_obj = json_decode($response_body, true);
         // Check for errors
         if (is_null($response_obj) || !is_array($response_obj) || !isset($response_obj['compiledCode']) || isset($response_obj['errors'], $response_obj['serverErrors'])) {
             return $js_code;
         }
         // Everything OK, let's first cache the JS code
         $js_code = $js_cache[$js_hash] = $response_obj['compiledCode'];
         if (!add_option('_youxi_minjs_cache', $js_cache, '', 'no')) {
             update_option('_youxi_minjs_cache', $js_cache);
         }
     }
     return $js_code;
 }
开发者ID:yemingyuen,项目名称:mingsg,代码行数:35,代码来源:class-js.php

示例14: acf_pro_get_remote_response

function acf_pro_get_remote_response($action = '', $post = array())
{
    // vars
    $url = acf_pro_get_remote_url($action);
    // connect
    $request = wp_remote_post($url, array('body' => $post));
    // error
    if (is_wp_error($request)) {
        // loop
        foreach ($request->errors as $k => $v) {
            // bail early if no error
            if (empty($v[0])) {
                continue;
            }
            // save
            acf_update_setting('remote_response_error', $k . ': ' . $v[0]);
            // only run once
            break;
        }
        // success
    } elseif (wp_remote_retrieve_response_code($request) === 200) {
        return $request['body'];
    }
    // return
    return 0;
}
开发者ID:Garth619,项目名称:Femi9,代码行数:26,代码来源:api-pro.php

示例15: zem_rp_upload_articles

function zem_rp_upload_articles($api_key)
{
    $media = array();
    foreach (zem_rp_get_all_attachments() as $image) {
        if (empty($media[$image->post_parent])) {
            $media[$image->post_parent] = array();
        }
        $meta = unserialize($image->meta);
        $media["{$image->post_parent}"][] = array("URL" => $image->guid, "width" => $meta['width'], "height" => $meta['height']);
    }
    $payload = array("found" => 0, "posts" => array());
    foreach (get_posts(array('numberposts' => 10000)) as $post) {
        $obj = array("ID" => $post->ID, "URL" => get_permalink($post->ID), "attachment_count" => 0, "attachments" => array(), "content" => $post->post_content, "date" => $post->post_date, "excerpt" => $post->post_excerpt, "featured_image" => "", "modified" => $post->post_modified, "post_thumbnail" => null, "slug" => $post->post_name, "status" => $post->post_status, "title" => $post->post_title, "type" => $post->post_type);
        if (has_post_thumbnail($post->ID)) {
            $thumb_id = get_post_thumbnail_id($post->ID);
            $meta = wp_get_attachment_metadata($thumb_id);
            $obj["post_thumbnail"] = array("URL" => wp_get_attachment_url($thumb_id), "width" => $meta["width"], "height" => $meta["height"]);
        }
        if (!empty($media[$post->ID])) {
            $obj["attachments"] = $media[$post->ID];
        }
        $obj["attachment_count"] = sizeof($obj["attachments"]);
        $payload["posts"][] = $obj;
    }
    $payload["found"] = sizeof($payload["posts"]);
    $payload["posts"] = $payload["posts"];
    $http_response = wp_remote_post(ZEM_RP_ZEMANTA_UPLOAD_URL, array("body" => array("payload" => json_encode($payload), "blog_name" => get_bloginfo('name'), "api_key" => $api_key, "feed_url" => get_bloginfo('rss2_url'), "blog_url" => get_bloginfo('url'), "platform" => 'wordpress-zem')));
    if (!is_wp_error($http_response) && wp_remote_retrieve_response_code($http_response) == 200) {
        $response = json_decode(wp_remote_retrieve_body($http_response));
        return $response->status === 'ok';
    }
    return false;
}
开发者ID:se7ven214,项目名称:Kungfuphp.local,代码行数:33,代码来源:uploader.php


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