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


PHP wp_safe_remote_post函数代码示例

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


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

示例1: parse_gateway_notification

 /**
  * parse_gateway_notification method, receives data from the payment gateway
  * @access private
  */
 function parse_gateway_notification()
 {
     /// PayPal first expects the IPN variables to be returned to it within 30 seconds, so we do this first.
     if ('sandbox' == get_option('paypal_certified_server_type')) {
         $paypal_url = "https://www.sandbox.paypal.com/webscr";
     } else {
         $API_Endpoint = "https://api-3t.paypal.com/nvp";
         $paypal_url = "https://www.paypal.com/cgi-bin/webscr";
     }
     $received_values = array();
     $received_values['cmd'] = '_notify-validate';
     $received_values += stripslashes_deep($_POST);
     $options = array('timeout' => 20, 'body' => $received_values, 'httpversion' => '1.1', 'user-agent' => 'WP eCommerce/' . WPSC_PRESENTABLE_VERSION);
     $response = wp_safe_remote_post($paypal_url, $options);
     do_action('wpsc_paypal_express_ipn', $received_values, $this);
     if ('VERIFIED' == $response['body']) {
         $this->paypal_ipn_values = $received_values;
         $this->session_id = $received_values['invoice'];
         if (strtolower($received_values['payment_status']) == 'completed') {
             $this->set_purchase_processed_by_sessionid(3);
             transaction_results($this->session_id, false);
         } elseif (strtolower($received_values['payment_status']) == 'denied') {
             $this->set_purchase_processed_by_sessionid(6);
         }
     } else {
         exit("IPN Request Failure");
     }
 }
开发者ID:ashik968,项目名称:digiplot,代码行数:32,代码来源:paypal-express.merchant.php

示例2: send_tracking_data

 /**
  * Decide whether to send tracking data or not.
  *
  * @param bool $override
  */
 public static function send_tracking_data($override = false)
 {
     // Don't trigger this on AJAX Requests
     if (defined('DOING_AJAX') && DOING_AJAX) {
         return;
     }
     if (!self::is_allow_track()) {
         return;
     }
     if (!apply_filters('elementor/tracker/send_override', $override)) {
         // Send a maximum of once per week by default.
         $last_send = self::_get_last_send_time();
         if ($last_send && $last_send > apply_filters('elementor/tracker/last_send_interval', strtotime('-1 week'))) {
             return;
         }
     } else {
         // Make sure there is at least a 1 hour delay between override sends, we dont want duplicate calls due to double clicking links.
         $last_send = self::_get_last_send_time();
         if ($last_send && $last_send > strtotime('-1 hours')) {
             return;
         }
     }
     // Update time first before sending to ensure it is set
     update_option('elementor_tracker_last_send', time());
     // Send here..
     $params = ['system' => self::_get_system_reports_data(), 'site_lang' => get_bloginfo('language'), 'email' => get_option('admin_email'), 'usages' => ['posts' => self::_get_posts_usage(), 'library' => self::_get_library_usage()]];
     add_filter('https_ssl_verify', '__return_false');
     $response = wp_safe_remote_post(self::$_api_url, ['timeout' => 25, 'blocking' => false, 'body' => ['data' => wp_json_encode($params)]]);
 }
开发者ID:pojome,项目名称:elementor,代码行数:34,代码来源:tracker.php

示例3: validate_transaction

 /**
  * Validate a PDT transaction to ensure its authentic
  * @param  string $transaction
  * @return bool
  */
 protected function validate_transaction($transaction)
 {
     $pdt = array('body' => array('cmd' => '_notify-synch', 'tx' => $transaction, 'at' => $this->identity_token), 'timeout' => 60, 'httpversion' => '1.1', 'user-agent' => 'WooCommerce/' . WC_VERSION);
     // Post back to get a response
     $response = wp_safe_remote_post($this->sandbox ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $pdt);
     if (is_wp_error($response) || !strpos($response['body'], "SUCCESS") === 0) {
         return false;
     }
     return true;
 }
开发者ID:CannedHead,项目名称:feelingsurf,代码行数:15,代码来源:class-wc-gateway-paypal-pdt-handler.php

示例4: perform_action

 /**
  * Performs an HTTP POST to the specified URL with the CSV
  *
  * @since 3.0
  * @param string $filename unused
  * @param string $csv the CSV to include the HTTP POST body
  * @throws Exception WP HTTP error handling
  */
 public function perform_action($filename, $csv)
 {
     $args = apply_filters('wc_customer_order_csv_export_http_post_args', array('timeout' => 60, 'redirection' => 0, 'httpversion' => '1.0', 'sslverify' => true, 'blocking' => true, 'headers' => array('accept' => 'text/csv', 'content-type' => 'text/csv'), 'body' => $csv, 'cookies' => array(), 'user-agent' => "WordPress " . $GLOBALS['wp_version']));
     $response = wp_safe_remote_post(get_option('wc_customer_order_csv_export_http_post_url'), $args);
     // check for errors
     if (is_wp_error($response)) {
         throw new Exception($response->get_error_message());
     }
     // log responses
     wc_customer_order_csv_export()->log(print_r($response, true));
 }
开发者ID:arobbins,项目名称:spellestate,代码行数:19,代码来源:class-wc-customer-order-csv-export-method-http-post.php

示例5: executePayPalRequest

 private function executePayPalRequest($postData)
 {
     $args = array('body' => $postData, 'timeout' => 60, 'httpversion' => '1.1', 'compress' => false, 'decompress' => false, 'user-agent' => 'AffiliatesManager/' . WPAM_VERSION);
     $response = wp_safe_remote_post($this->apiEndPoint, $args);
     if (is_wp_error($response)) {
         throw new WPAM_PayPal_ServiceException(sprintf(__("POST failed\nerrors:\n%serrordata:\n%s", 'affiliates-manager'), print_r($response->errors, true), print_r($response->error_data, true)));
     } elseif (isset($response['response']['code']) && $response['response']['code'] == 200) {
         return $response['body'];
     }
     throw new WPAM_PayPal_ServiceException(sprintf(__('Unknown response: %s', 'affiliates-manager'), print_r($response, true)));
 }
开发者ID:wp-insider,项目名称:affiliates-manager-plugin,代码行数:11,代码来源:Service.php

示例6: grav_paypal_sandbox_ipn_tester

function grav_paypal_sandbox_ipn_tester()
{
    if (!empty($_GET['ipn-test']) && current_user_can('manage_options')) {
        $response = wp_safe_remote_post('https://www.sandbox.paypal.com/cgi-bin/webscr', array('body' => array('test_ipn' => 1, 'cmd' => '_notify-validate')));
        if (!is_wp_error($response)) {
            wp_die('Test successful!  No changes need to be made.');
        } else {
            wp_die('Test failed.  You will need to update your hosting environment.  Failure response: ' . $response->get_error_message());
        }
    }
}
开发者ID:jpopgravitate,项目名称:paypal-test,代码行数:11,代码来源:PPSHA256-test.php

示例7: do_request

 /**
  * @param $url
  * @param $parameters
  *
  * @return array|bool
  * @throws Exception
  */
 function do_request($url, $args)
 {
     // request (http://websupporter.net/blog/wp_remote_get-vs-wp_safe_remote_get-2/)
     $response = wp_safe_remote_post($url, $args);
     $body = wp_remote_retrieve_body($response);
     // evaluate body
     if (is_array($response) && $response['response']['code'] === 200) {
         return $this->parse_downloadlinks($body);
     } else {
         throw new Exception(__('An error occurred while watermarking. Please check your BooXtream Dashboard: ', 'woocommerce_booxtream'));
     }
 }
开发者ID:BooXtream,项目名称:BooXtream-WooCommerce,代码行数:19,代码来源:class-wc-booxtream-request.php

示例8: refund_transaction

 /**
  * Refund an order via PayPal.
  * @param  WC_Order $order
  * @param  float    $amount
  * @param  string   $reason
  * @return object Either an object of name value pairs for a success, or a WP_ERROR object.
  */
 public static function refund_transaction($order, $amount = null, $reason = '')
 {
     $raw_response = wp_safe_remote_post(self::$sandbox ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp', array('method' => 'POST', 'body' => self::get_refund_request($order, $amount, $reason), 'timeout' => 70, 'user-agent' => 'WooCommerce/' . WC()->version, 'httpversion' => '1.1'));
     WC_Gateway_Paypal::log('Refund Response: ' . print_r($raw_response, true));
     if (empty($raw_response['body'])) {
         return new WP_Error('paypal-api', 'Empty Response');
     } elseif (is_wp_error($raw_response)) {
         return $raw_response;
     }
     parse_str($raw_response['body'], $response);
     return (object) $response;
 }
开发者ID:pelmered,项目名称:woocommerce,代码行数:19,代码来源:class-wc-gateway-paypal-api-handler.php

示例9: refund_order

 /**
  * Refund an order via PayPal
  * @param  WC_Order $order
  * @param  float $amount
  * @param  string $reason
  * @param  boolean $sandbox
  * @return array|wp_error The parsed response from paypal, or a WP_Error object
  */
 public static function refund_order($order, $amount = null, $reason = '', $sandbox = false)
 {
     $response = wp_safe_remote_post($sandbox ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp', array('method' => 'POST', 'body' => self::get_request($order, $amount, $reason), 'timeout' => 70, 'user-agent' => 'WooCommerce', 'httpversion' => '1.1'));
     if (is_wp_error($response)) {
         return $response;
     }
     if (empty($response['body'])) {
         return new WP_Error('paypal-refunds', 'Empty Response');
     }
     parse_str($response['body'], $response_array);
     return $response_array;
 }
开发者ID:flasomm,项目名称:Montkailash,代码行数:20,代码来源:class-wc-gateway-paypal-refund.php

示例10: wpsc_do_delete_visitor_ajax

/**
 * Request a visitor be deleted via the WordPRess admin ajax path
 *
 * @access private
 * @since 3.8.14
 *
 * @param int $visitor_id
 *
 * @return boolean, true on success, false on failure
 *
 */
function wpsc_do_delete_visitor_ajax($visitor_id)
{
    $delete_visitor_nonce_action = 'wpsc_delete_visitor_id_' . $visitor_id;
    $wpsc_security = wp_create_nonce($delete_visitor_nonce_action);
    $response = wp_safe_remote_post(admin_url('admin-ajax.php'), array('method' => 'POST', 'timeout' => 15, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array(), 'body' => array('action' => 'wpsc_delete_visitor', 'wpsc_visitor_id' => $visitor_id, 'wpsc_security' => $wpsc_security), 'cookies' => array()));
    if (is_wp_error($response)) {
        $result = false;
    } else {
        $result = true;
    }
    return $result;
}
开发者ID:ashik968,项目名称:digiplot,代码行数:23,代码来源:cron.php

示例11: post

 /**
  * Sends a POST request with the given article and bundles.
  *
  * @param string $url
  * @param string $article
  * @param array $bundles
  * @param array $meta
  * @return mixed
  * @since 0.2.0
  */
 public function post($url, $article, $bundles = array(), $meta = null)
 {
     // Assemble the content to send
     $content = $this->build_content($article, $bundles, $meta);
     // Build the post request args
     $args = array('headers' => array('Authorization' => $this->sign($url, 'POST', $content), 'Content-Length' => strlen($content), 'Content-Type' => 'multipart/form-data; boundary=' . $this->mime_builder->boundary()), 'body' => $content);
     // Allow filtering and merge with the default args
     $args = apply_filters('apple_news_post_args', wp_parse_args($args, $this->default_args));
     // Perform the request
     $response = wp_safe_remote_post(esc_url_raw($url), $args);
     // Parse and return the response
     return $this->parse_response($response);
 }
开发者ID:mattheu,项目名称:apple-news,代码行数:23,代码来源:class-request.php

示例12: send_to_zapier

 private static function send_to_zapier($target_url, $data)
 {
     if (strpos($target_url, 'zapier.com/hooks') === false) {
         return;
     }
     $headers = array();
     if (empty($data)) {
         $headers['X-Hook-Test'] = 'true';
     }
     $post_args = array('headers' => $headers, 'body' => wp_json_encode($data), 'timeout' => apply_filters('http_request_timeout', 15), 'sslverify' => false, 'ssl' => true);
     $resp = wp_safe_remote_post($target_url, $post_args);
     if ($resp) {
         // If 410 header than unsubscribe the zap
     }
 }
开发者ID:danielbachhuber,项目名称:marcgratch.com,代码行数:15,代码来源:Zapier_API.php

示例13: is_valid_ipn_request

 /**
  * Check with PayPal whether posted data is valid IPN request.
  *
  * @throws Exception
  *
  * @param array $posted_data Posted data
  * @return bool True if posted_data is valid IPN request
  */
 public function is_valid_ipn_request(array $posted_data)
 {
     wc_gateway_ppec_log(sprintf('%s: %s', __FUNCTION__, 'Checking IPN request validity'));
     $ipn_request = array('cmd' => '_notify-validate');
     $ipn_request += wp_unslash($posted_data);
     $params = array('body' => $ipn_request, 'timeout' => 60, 'httpversion' => '1.1', 'compress' => false, 'decompress' => false, 'user-agent' => get_class($this->gateway));
     // Post back to PayPal to check validity of IPN request.
     $response = wp_safe_remote_post($this->get_validator_url(), $params);
     wc_gateway_ppec_log(sprintf('%s: %s: %s', __FUNCTION__, 'Verify IPN request', print_r($params, true)));
     wc_gateway_ppec_log(sprintf('%s: %s: %s', __FUNCTION__, 'Response for the IPN request', print_r($response, true)));
     if (is_wp_error($response)) {
         throw new Exception($response->get_error_message());
     }
     return $response['response']['code'] >= 200 && $response['response']['code'] < 300 && strstr($response['body'], 'VERIFIED');
 }
开发者ID:ksan5835,项目名称:maadithottam,代码行数:23,代码来源:class-wc-gateway-ppec-ipn-handler.php

示例14: rcp_validate_captcha

function rcp_validate_captcha($data)
{
    global $rcp_options;
    if (!isset($rcp_options['enable_recaptcha']) || empty($rcp_options['recaptcha_public_key']) || empty($rcp_options['recaptcha_private_key'])) {
        return;
    }
    if (empty($data['g-recaptcha-response']) || empty($data['g-recaptcha-remoteip'])) {
        rcp_errors()->add('invalid_recaptcha', __('Please verify that you are not a robot', 'rcp'), 'register');
        return;
    }
    $verify = wp_safe_remote_post('https://www.google.com/recaptcha/api/siteverify', array('body' => array('secret' => trim($rcp_options['recaptcha_private_key']), 'response' => $data['g-recaptcha-response'], 'remoteip' => $data['g-recaptcha-remoteip'])));
    $verify = json_decode(wp_remote_retrieve_body($verify));
    if (empty($verify->success) || true !== $verify->success) {
        rcp_errors()->add('invalid_recaptcha', __('Please verify that you are not a robot', 'rcp'), 'register');
    }
}
开发者ID:alirezism,项目名称:restrict-content-pro,代码行数:16,代码来源:captcha-functions.php

示例15: verify

 public function verify($response_token)
 {
     $is_human = false;
     if (empty($response_token)) {
         return $is_human;
     }
     $url = self::VERIFY_URL;
     $sitekey = $this->get_sitekey();
     $secret = $this->get_secret($sitekey);
     $response = wp_safe_remote_post($url, array('body' => array('secret' => $secret, 'response' => $response_token, 'remoteip' => $_SERVER['REMOTE_ADDR'])));
     if (200 != wp_remote_retrieve_response_code($response)) {
         return $is_human;
     }
     $response = wp_remote_retrieve_body($response);
     $response = json_decode($response, true);
     $is_human = isset($response['success']) && true == $response['success'];
     return $is_human;
 }
开发者ID:SpatialMetabolomics,项目名称:metaspace-website,代码行数:18,代码来源:recaptcha.php


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