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

PHP wp_remote_request函数代码示例

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

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



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

示例1: make_request

 /**
  * Make API request.
  * 
  * @access public
  * @param string $path
  * @param array $options
  * @param bool $return_status (default: false)
  * @param string $method (default: 'GET')
  * @return void
  */
 function make_request($path, $options = array(), $method = 'GET', $return_key = null)
 {
     /* Build base request options string. */
     $request_options = '?format=json&auth_token=' . $this->oauth_token;
     /* Add options if this is a GET request. */
     $request_options .= $method == 'GET' ? '&' . http_build_query($options) : null;
     /* Build request URL. */
     $request_url = $this->api_url . $path . $request_options;
     /* Setup request arguments. */
     $args = array('method' => $method, 'sslverify' => $this->verify_ssl);
     /* Add request options to body of POST and PUT requests. */
     if ($method == 'POST' || $method == 'PUT') {
         $args['body'] = $options;
     }
     /* Execute request. */
     $result = wp_remote_request($request_url, $args);
     /* If WP_Error, throw exception */
     if (is_wp_error($result)) {
         throw new Exception('Request failed. ' . $result->get_error_messages());
     }
     /* Decode JSON. */
     $decoded_result = json_decode($result['body'], true);
     /* If invalid JSON, return original result body. */
     if (json_last_error() !== JSON_ERROR_NONE) {
         return $result['body'];
     }
     /* If return key is set and exists, return array item. */
     if ($return_key && array_key_exists($return_key, $decoded_result)) {
         return $decoded_result[$return_key];
     }
     return $decoded_result;
 }
开发者ID:wp-premium,项目名称:gravityformshipchat,代码行数:42,代码来源:class-hipchat.php


示例2: PATCH

 public static function PATCH($url, $headers = array(), $data = array())
 {
     if (function_exists("wp_remote_request")) {
         return wp_remote_request($url, array("headers" => $headers, "body" => $data));
     }
     return Requests::patch($url, $headers, $data);
 }
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:7,代码来源:Client.php


示例3: request

 /**
  * Override the curl-based function to use baseline WordPress
  */
 protected function request($options)
 {
     if (!$this->api_token) {
         return FALSE;
     }
     //end if
     $url = $this->api_url . $options['function'];
     $args = array('method' => $options['method'], 'user-agent' => $this->useragent, 'headers' => array('Token' => $this->api_token, 'Content-Type' => 'application/json'), 'sslverify' => $this->ssl_verifypeer);
     if ('POST' == $options['method'] || 'PUT' == $options['method']) {
         $args['body'] = json_encode($options['data']);
     }
     //end if
     $res = wp_remote_request(esc_url_raw($url), $args);
     if (is_wp_error($res)) {
         return FALSE;
     }
     //end if
     // the following variables are primarily for debugging purposes
     // Let's utilise the WP Remote functions to retrieve metadata
     $this->request_http_code = wp_remote_retrieve_response_code($res);
     $this->request_info = $res;
     $this->request_url = $url;
     $this->request_response = wp_remote_retrieve_body($res);
     $return = json_decode($this->request_response);
     return $return ?: $this->request_response;
 }
开发者ID:rickalee,项目名称:headlineenvy,代码行数:29,代码来源:wp-optimizely.php


示例4: send_request

 /**
  * Send request with the specified action and parameters
  *
  * @param string $action
  * @param array $parameters
  */
 private function send_request($end_point, $method = 'GET', array $data = array(), $expected_response_code = 200)
 {
     // Request
     $url = self::API_URL . $end_point;
     $response = wp_remote_request($url, array('method' => $method, 'headers' => array('Authorization' => 'Bearer ' . $this->api_key), 'body' => $data));
     // Response code
     $response_code = wp_remote_retrieve_response_code($response);
     if ($expected_response_code != $response_code) {
         // WPCS: loose comparison ok.
         $this->error = new WP_Error('mollie_error', 'Unexpected response code.');
     }
     // Body
     $body = wp_remote_retrieve_body($response);
     $data = json_decode($body);
     if (!is_object($data)) {
         $this->error = new WP_Error('mollie_error', 'Could not parse response.');
         return false;
     }
     // Mollie error
     if (isset($data->error, $data->error->message)) {
         $this->error = new WP_Error('mollie_error', $data->error->message, $data->error);
         return false;
     }
     return $data;
 }
开发者ID:wp-pay-gateways,项目名称:mollie,代码行数:31,代码来源:Client.php


示例5: update

 public function update($body, $path)
 {
     global $wp_version;
     $params = array('api_key' => $this->api_key, 'expires' => time() + 900);
     $path = '/v2/assets/' . $path;
     $params['signature'] = $this->sign_request(array('path' => $path, 'method' => 'PATCH', 'body' => $body), $params);
     foreach ($params as &$param) {
         $param = rawurlencode($param);
     }
     $url = add_query_arg($params, 'https://api.ooyala.com' . $path);
     if ($wp_version >= 3.4) {
         return wp_remote_request($url, array('headers' => array('Content-Type' => 'application/json'), 'method' => 'PATCH', 'body' => $body, 'timeout' => apply_filters('ooyala_http_request_timeout', 10)));
     }
     // Workaround for core bug - http://core.trac.wordpress.org/ticket/18589
     $curl = curl_init($url);
     curl_setopt($curl, CURLOPT_HEADER, false);
     curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
     curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
     curl_setopt($curl, CURLOPT_POSTFIELDS, $body);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     $response = curl_exec($curl);
     $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
     curl_close($curl);
     return array('body' => $response, 'response' => array('code' => $status));
 }
开发者ID:humanmade,项目名称:vip-mu-plugins-public,代码行数:25,代码来源:class-wp-ooyala-backlot-api.php


示例6: get_version_info

 function get_version_info($cache = true)
 {
     $raw_response = get_transient('slideshow_update_info');
     if (!$cache) {
         $raw_response = false;
     }
     if (!$raw_response) {
         $options = array('method' => 'POST', 'timeout' => 20);
         $options['headers'] = array('Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'), 'User-Agent' => 'WordPress/' . get_bloginfo("version"), 'Referer' => home_url());
         $request_url = SLIDESHOW_MANAGER_URL . 'updates/13/' . $this->get_remote_request_params();
         $raw_response = wp_remote_request($request_url, $options);
         set_transient('slideshow_update_info', $raw_response, 43200);
     }
     if (is_wp_error($raw_response) || 200 != $raw_response['response']['code']) {
         return array("is_valid_key" => "1", "version" => "", "url" => "");
     } else {
         $array = explode("||", $raw_response['body']);
         $url = $array[2];
         //$url = "https://downloads.wordpress.org/plugin/slideshow-gallery.latest-stable.zip";
         $info = array("is_valid_key" => $array[0], "version" => $array[1], "url" => $url, "item_id" => $array[4]);
         if (count($array) == 4) {
             $info["expiration_time"] = $array[3];
         }
         return $info;
     }
 }
开发者ID:networksoft,项目名称:sharesystem.co,代码行数:26,代码来源:class.update.php


示例7: __construct

 function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false)
 {
     $this->url = $url;
     $this->timeout = $timeout;
     $this->redirects = $redirects;
     $this->headers = $headers;
     $this->useragent = $useragent;
     $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE;
     if (preg_match('/^http(s)?:\\/\\//i', $url)) {
         $args = array('timeout' => $this->timeout, 'redirection' => $this->redirects, 'reject_unsafe_urls' => true);
         if (!empty($this->headers)) {
             $args['headers'] = $this->headers;
         }
         if (SIMPLEPIE_USERAGENT != $this->useragent) {
             //Use default WP user agent unless custom has been specified
             $args['user-agent'] = $this->useragent;
         }
         $res = wp_remote_request($url, $args);
         if (is_wp_error($res)) {
             $this->error = 'WP HTTP Error: ' . $res->get_error_message();
             $this->success = false;
         } else {
             $this->headers = wp_remote_retrieve_headers($res);
             $this->body = wp_remote_retrieve_body($res);
             $this->status_code = wp_remote_retrieve_response_code($res);
         }
     } else {
         $this->error = '';
         $this->success = false;
     }
 }
开发者ID:jospintedjou,项目名称:wordpress,代码行数:31,代码来源:class-feed.php


示例8: http

 function http($url, $method, $postfields = NULL)
 {
     $this->http_info = null;
     // this is never used
     $options = array('method' => $method, 'timeout' => $this->timeout, 'user-agent' => $this->useragent, 'sslverify' => $this->ssl_verifypeer);
     switch ($method) {
         case 'POST':
             if (!empty($postfields)) {
                 $options['body'] = $postfields;
             }
             break;
         case 'DELETE':
             if (!empty($postfields)) {
                 $url = "{$url}?{$postfields}";
             }
     }
     $response = wp_remote_request($url, $options);
     if (is_wp_error($response)) {
         $this->http_code = null;
         $this->http_header = array();
         return false;
     }
     $this->http_code = $response['response']['code'];
     $this->http_header = $response['headers'];
     return $response['body'];
 }
开发者ID:rmccue,项目名称:TwitterOAuthWP,代码行数:26,代码来源:TwitterOAuthWP.php


示例9: locate

 function locate($ip = null)
 {
     global $_SERVER;
     if (is_null($ip)) {
         $ip = $_SERVER['REMOTE_ADDR'];
     }
     $host = str_replace('{IP}', $ip, $this->host);
     $host = str_replace('{CURRENCY}', $this->currency, $host);
     $data = array();
     /* Updated this class so it uses wp_remote_request instead of curl */
     $geodata = wp_remote_request($host);
     if (!empty($geodata)) {
         $response = $geodata['body'];
         $data = unserialize($response);
         //set the geoPlugin vars
         $this->ip = $ip;
         $this->city = $data['geoplugin_city'];
         $this->region = $data['geoplugin_region'];
         $this->areaCode = $data['geoplugin_areaCode'];
         $this->dmaCode = $data['geoplugin_dmaCode'];
         $this->countryCode = $data['geoplugin_countryCode'];
         $this->countryName = $data['geoplugin_countryName'];
         $this->continentCode = $data['geoplugin_continentCode'];
         $this->latitude = $data['geoplugin_latitude'];
         $this->longitude = $data['geoplugin_longitude'];
         $this->currencyCode = $data['geoplugin_currencyCode'];
         $this->currencySymbol = $data['geoplugin_currencySymbol'];
         $this->currencyConverter = $data['geoplugin_currencyConverter'];
     }
 }
开发者ID:phanhoanglong2610,项目名称:flowershop,代码行数:30,代码来源:geoplugin.class.php


示例10: send

 /**
  * Send the data to the collection server
  *
  * @since 2.1.0
  * @return array|mixed
  */
 public function send()
 {
     // Set the destination URL.
     $url = 'https://trends.optinmonster.com/api/v1/site';
     // Bring in the data.
     $body = $this->data;
     // Add the site ID to the URL and token to the body if we're updating.
     if ('PUT' == $this->request_type) {
         $url = $url . '/' . $this->auth['id'];
         $body['token'] = $this->auth['token'];
     }
     // JSON encode the body for sending.
     $body = json_encode($body);
     // Setup the request arguments.
     $args = array('method' => $this->request_type, 'headers' => array('Content-Type' => 'application/json', 'Content-Length' => strlen($body)), 'body' => $body);
     // Disable SSL checking.
     add_filter('http_request_args', array($this, 'http_request_args'), 10, 2);
     // Onward!
     $response = wp_remote_request($url, $args);
     // Decode the returned data.
     $returned = json_decode(wp_remote_retrieve_body($response));
     // Save the auth data if it was a first-time request.
     if ('POST' == $this->request_type && property_exists($returned, 'data')) {
         update_option('awesomemotive_auth', (array) $returned->data);
     }
     return $returned;
 }
开发者ID:venturepact,项目名称:blog,代码行数:33,代码来源:reporter.php


示例11: makeRequest

 /**
  * @param string $crowdskoutUrl
  * @param string $type
  *
  * @return array|WP_Error
  */
 protected function makeRequest($crowdskoutUrl, $type)
 {
     $cskt_request = json_encode(array('url' => $this->url, 'topics' => $this->topics));
     /** Send Request to the Crowdskout Database */
     $response = wp_remote_request($crowdskoutUrl, array('method' => $type, 'headers' => array('Content-Type' => 'application/json'), 'body' => $cskt_request));
     return $response;
 }
开发者ID:Elite50,项目名称:crowdskout-wp,代码行数:13,代码来源:topics.php


示例12: remote

 public static function remote($url = FALSE, $post_vars = FALSE, $args = array())
 {
     static $http_response_filtered = false;
     /* Apply GZ filters only once. */
     /**/
     $args = !is_array($args) ? array() : $args;
     /* Disable SSL verifications. */
     $args["sslverify"] = !isset($args["sslverify"]) ? false : $args["sslverify"];
     /**/
     if (!$http_response_filtered && ($http_response_filtered = true)) {
         add_filter("http_response", "c_ws_plugin__qcache_utils_urls::_remote_gz_variations");
     }
     /**/
     if ($url) {
         if (preg_match("/^https/i", $url) && strtolower(substr(PHP_OS, 0, 3)) === "win") {
             add_filter("use_curl_transport", "__return_false", $curl_disabled = 1352);
         }
         /**/
         if ((is_array($post_vars) || is_string($post_vars)) && !empty($post_vars)) {
             $args = array_merge($args, array("method" => "POST", "body" => $post_vars));
         }
         /**/
         $body = wp_remote_retrieve_body(wp_remote_request($url, $args));
         /**/
         if ($curl_was_disabled_by_this_routine_with_1352_priority = $curl_disabled) {
             remove_filter("use_curl_transport", "__return_false", 1352);
         }
         /**/
         return $body;
         /* The body content received. */
     }
     /**/
     return false;
     /* Else return false. */
 }
开发者ID:Weissenberger13,项目名称:web.portugalrentalcottages,代码行数:35,代码来源:utils-urls.inc.php


示例13: make_request

 /**
  * Make API request.
  * 
  * @access public
  * @param string $action
  * @param array $options (default: array())
  * @param string $method (default: 'GET')
  * @return void
  */
 public function make_request($action = null, $options = array(), $method = 'GET', $return_key = null)
 {
     /* Build request options string. */
     $request_options = $method == 'GET' && !empty($options) ? '?' . http_build_query($options) : '';
     /* Build request URL. */
     $request_url = $this->api_url . $action . $request_options;
     /* Prepare request and execute. */
     $args = array('headers' => $this->request_headers(), 'method' => $method);
     if ($method == 'POST') {
         $args['body'] = json_encode($options);
     }
     $response = wp_remote_request($request_url, $args);
     /* If WP_Error, die. Otherwise, return decoded JSON. */
     if (is_wp_error($response)) {
         die('Request failed. ' . $response->get_error_message());
     } else {
         $response = json_decode($response['body'], true);
         if (isset($response['errors'])) {
             throw new Exception($response['errors'][0]);
         }
         if (isset($response['warnings'])) {
             throw new Exception($response['warnings'][0]);
         }
         return empty($return_key) ? $response : $response[$return_key];
     }
 }
开发者ID:wp-premium,项目名称:gravityformsicontact,代码行数:35,代码来源:class-icontact.php


示例14: __construct

 function __construct($data)
 {
     // This could be a URL, an wp_remote_request() return value,
     // or just some JSON/JSONP in a string.
     if (is_string($data)) {
         // See if it parses.
         $this->text = $data;
         $this->parse();
         if (is_null($this->data)) {
             // Does it look like a URL?
             $bits = parse_url($this->text);
             if (isset($bits['scheme'])) {
                 $this->text = NULL;
                 $this->url = $data;
                 $data = wp_remote_request($this->url);
             }
         }
     }
     if (is_null($this->data) and $this->is_jsonp($data)) {
         // Got a HTTP reply from wp_remote_request
         $this->text = $data['body'];
     } else {
         $this->text = NULL;
     }
     if (!is_null($this->text)) {
         $this->parse();
     }
 }
开发者ID:radgeek,项目名称:occupysandy,代码行数:28,代码来源:sahanageojsonp.class.php


示例15: _purge_content

 /**
  * Purge content
  *
  * @param string $path
  * @param int $type
  * @param string $error
  * @return boolean
  */
 function _purge_content($path, $type, &$error)
 {
     $url = sprintf(W3TC_CDN_EDGECAST_PURGE_URL, $this->_config['account']);
     $args = array('method' => 'PUT', 'user-agent' => W3TC_POWERED_BY, 'headers' => array('Accept' => 'application/json', 'Content-Type' => 'application/json', 'Authorization' => sprintf('TOK:%s', $this->_config['token'])), 'body' => json_encode(array('MediaPath' => $path, 'MediaType' => $type)));
     $response = wp_remote_request($url, $args);
     if (is_wp_error($response)) {
         $error = implode('; ', $response->get_error_messages());
         return false;
     }
     switch ($response['response']['code']) {
         case 200:
             return true;
         case 400:
             $error = __('Invalid Request Parameter', 'w3-total-cache');
             return false;
         case 403:
             $error = __('Authentication Failure or Insufficient Access Rights', 'w3-total-cache');
             return false;
         case 404:
             $error = __('Invalid Request URI', 'w3-total-cache');
             return false;
         case 405:
             $error = __('Invalid Request', 'w3-total-cache');
             return false;
         case 500:
             $error = __('Server Error', 'w3-total-cache');
             return false;
     }
     $error = 'Unknown error';
     return false;
 }
开发者ID:gumbysgoo,项目名称:bestilblomster,代码行数:39,代码来源:Edgecast.php


示例16: aaTeamServerValidate

 public function aaTeamServerValidate()
 {
     // fake return, just for development
     $input = array();
     // validation link
     $input = wp_remote_request('http://www.96down.com/api/verifypsp.php?ipc=' . urlencode($_REQUEST['ipc']) . '&email=' . urlencode($_REQUEST['email']) . '&app=' . self::ALIAS);
     // try to access the envato returns
     $aaTeamServer_return = json_decode($input['body'], true);
     if ($aaTeamServer_return['status'] == 'valid') {
         $envato_return = $aaTeamServer_return['envato_obj'];
         if (count($envato_return) > 1) {
             update_option(self::ALIAS . '_register_key', $_REQUEST['ipc']);
             update_option(self::ALIAS . '_register_email', $_REQUEST['email']);
             update_option(self::ALIAS . '_register_buyer', $envato_return['buyer']);
             update_option(self::ALIAS . '_register_item_id', $envato_return['item-id']);
             update_option(self::ALIAS . '_register_licence', $envato_return['licence']);
             update_option(self::ALIAS . '_register_item_name', $envato_return['item-name']);
             // generate the hash marker
             $hash = md5($this->encrypt($_REQUEST['ipc']));
             // update to db the hash for plugin
             update_option(self::ALIAS . '_hash', $hash);
             die(json_encode(array('status' => 'OK')));
         }
     }
     die(json_encode(array('status' => 'ERROR', 'msg' => 'Unable to validate this plugin. Please contact AA-Team Support!')));
 }
开发者ID:shahadat014,项目名称:geleyi,代码行数:26,代码来源:validation.php


示例17: fn_sb_movie_infobox_cache

function fn_sb_movie_infobox_cache($id, $detailType)
{
    //    $cacheage = get_option('imdbcacheage', -1);
    $cacheage = -1;
    $imageCacheDir = SB_CACHE_DIR . "/" . $id . ".jpg";
    $imageCacheUrl = SB_CACHE_URL . "/" . $id . ".jpg";
    $jsonCacheDir = SB_CACHE_DIR . "/" . $id . ".json";
    if (!file_exists($imageCacheDir) || $cacheage > -1 && filemtime($imageCacheDir) < time() - $cacheage || !file_exists($jsonCacheDir) || $cacheage > -1 && filemtime($jsonCacheDir) < time() - $cacheage) {
        //$url = "http://www.omdbapi.com/?i=".$movieid."&plot=short&r=json";
        $url = "http://www.omdbapi.com/?i={$id}&plot={$detailType}&r=json";
        $http_args = array('user-agent' => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)');
        $rawResponse = wp_remote_request($url, $http_args);
        $rawResponse = $rawResponse['body'];
        //        $raw = file_get_contents_curl('http://www.omdbapi.com/?i=' . $id."&plot=short&r=json");
        $json = json_decode($rawResponse, true);
        $jsonResult = file_put_contents($jsonCacheDir, $rawResponse);
        //        echo("jsonResult". $jsonResult . "<br/>");
        $img = file_get_contents_curl($json['Poster']);
        $jsonResult = file_put_contents($imageCacheDir, $img);
        $json['Poster'] = $imageCacheUrl;
    } else {
        $rawResponse = file_get_contents($jsonCacheDir);
        $json = json_decode($rawResponse, true);
        $json['Poster'] = $imageCacheUrl;
    }
    return $json;
}
开发者ID:ScriptonBasestar,项目名称:sb-review-infobox,代码行数:27,代码来源:shortcodes-imdb.php


示例18: make_request

 /**
  * Make API request.
  * 
  * @access public
  * @param string $action
  * @param array $options (default: array())
  * @param string $method (default: 'GET')
  * @param int $expected_code (default: 200)
  * @return array or int
  */
 function make_request($action, $options = array(), $method = 'GET', $expected_code = 200)
 {
     $request_options = $method == 'GET' ? '?' . http_build_query($options) : null;
     /* Build request URL. */
     $request_url = 'https://' . $this->account_url . '.agilecrm.com/dev/api/' . $action . $request_options;
     /* Setup request arguments. */
     $args = array('headers' => array('Accept' => 'application/json', 'Authorization' => 'Basic ' . base64_encode($this->email_address . ':' . $this->api_key), 'Content-Type' => 'application/json'), 'method' => $method, 'sslverify' => $this->verify_ssl);
     /* Add request options to body of POST and PUT requests. */
     if ($method == 'POST' || $method == 'PUT') {
         $args['body'] = $options;
     }
     /* Execute request. */
     $result = wp_remote_request($request_url, $args);
     /* If WP_Error, throw exception */
     if (is_wp_error($result)) {
         throw new Exception('Request failed. ' . $result->get_error_message());
     }
     /* If response code does not match expected code, throw exception. */
     if ($result['response']['code'] !== $expected_code) {
         if ($result['response']['code'] == 400) {
             throw new Exception('Input is in the wrong format.');
         } elseif ($result['response']['code'] == 401) {
             throw new Exception('API credentials invalid.');
         } else {
             throw new Exception(sprintf('%s: %s', $result['response']['code'], $result['response']['message']));
         }
     }
     return json_decode($result['body'], true);
 }
开发者ID:wp-premium,项目名称:gravityformsagilecrm,代码行数:39,代码来源:class-agilecrm-api.php


示例19: call

 /**
  * Execute an API call
  *
  * @access      public
  * @since       1.0.0
  * @param       int $customer_id The customer ID
  * @param       array $body The body of the API call
  * @param       string $method The type of call to make
  * @param       string $endpoint The endpoint to call
  * @return      mixed int $response If API call succeeded, false otherwise
  */
 public function call($customer_id = 0, $body = array(), $method = 'PUT', $endpoint = false)
 {
     // Bail if no ID or body passed
     if (!$customer_id || empty($body)) {
         return false;
     }
     $args = array('headers' => array('Authorization' => 'Basic ' . base64_encode($this->site_id . ':' . $this->api_key)), 'method' => $method, 'body' => $body);
     $url = $this->api_url . $customer_id;
     if ($endpoint) {
         $url .= '/' . $endpoint;
     }
     try {
         $response = wp_remote_request($url, $args);
     } catch (Exception $e) {
         edd_record_gateway_error(__('EDD Customer.io Connect Error', 'edd-customerio-connect'), print_r($e->getMessage(), true));
         return false;
     }
     $status = wp_remote_retrieve_header($response, 'status');
     if ($status != '200 OK') {
         $body = json_decode(wp_remote_retrieve_body($response));
         edd_record_gateway_error(__('EDD Customer.io Connect Error', 'edd-customerio-connect'), $status . ': ' . $body->meta->error);
         return false;
     }
     return $response;
 }
开发者ID:easydigitaldownloads,项目名称:EDD-Customerio-Connect,代码行数:36,代码来源:class.customerio.php


示例20: send_webhook

 function send_webhook()
 {
     $entry = $this->get_entry();
     $url = $this->url;
     $this->log_debug(__METHOD__ . '() - url before replacing variables: ' . $url);
     $url = GFCommon::replace_variables($url, $this->get_form(), $entry, true, false, false, 'text');
     $this->log_debug(__METHOD__ . '() - url after replacing variables: ' . $url);
     $method = strtoupper($this->method);
     $body = null;
     $headers = array();
     if (in_array($method, array('POST', 'PUT'))) {
         if ($this->format == 'json') {
             $headers = array('Content-type' => 'application/json');
             $body = json_encode($entry);
         } else {
             $headers = array();
             $body = $entry;
         }
     }
     $args = array('method' => $method, 'timeout' => 45, 'redirection' => 3, 'blocking' => true, 'headers' => $headers, 'body' => $body, 'cookies' => array());
     $args = apply_filters('gravityflow_webhook_args', $args, $entry, $this);
     $response = wp_remote_request($url, $args);
     $this->log_debug(__METHOD__ . '() - response: ' . print_r($response, true));
     if (is_wp_error($response)) {
         $step_status = 'error';
     } else {
         $step_status = 'success';
     }
     $note = esc_html__('Webhook sent. Url: ' . $url);
     $this->add_note($note, 0, 'webhook');
     do_action('gravityflow_post_webhook', $response, $args, $entry, $this);
     return $step_status;
 }
开发者ID:jakejackson1,项目名称:gravityflow,代码行数:33,代码来源:class-step-webhook.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP wp_remote_retrieve_body函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_remote_post函数代码示例发布时间: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