本文整理汇总了PHP中wp_safe_remote_post函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_safe_remote_post函数的具体用法?PHP wp_safe_remote_post怎么用?PHP wp_safe_remote_post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_safe_remote_post函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: idx_api
/**
* IDX API Request
*/
public function idx_api($method, $apiversion = Initiate_Plugin::IDX_API_DEFAULT_VERSION, $level = 'clients', $params = array(), $expiration = 7200, $request_type = 'GET', $json_decode_type = false)
{
$cache_key = 'idx_' . $method . '_cache';
if ($this->get_transient($cache_key) !== false) {
$data = $this->get_transient($cache_key);
return $data;
}
$headers = array('Content-Type' => 'application/x-www-form-urlencoded', 'accesskey' => $this->api_key, 'outputtype' => 'json', 'apiversion' => $apiversion, 'pluginversion' => \Idx_Broker_Plugin::IDX_WP_PLUGIN_VERSION);
if (function_exists('equity')) {
if ($level === 'equity') {
$equity_api_key = get_option('equity_api_key');
$domain = site_url();
$equity_headers = array('equitykey' => $equity_api_key, 'domain' => apply_filters('equity_idx_api_domain', $domain));
$headers = array_merge($headers, $equity_headers);
}
}
$params = array_merge(array('timeout' => 120, 'sslverify' => false, 'headers' => $headers), $params);
$url = Initiate_Plugin::IDX_API_URL . '/' . $level . '/' . $method;
if ($request_type === 'POST') {
$response = wp_safe_remote_post($url, $params);
} else {
$response = wp_remote_get($url, $params);
}
$response = (array) $response;
extract($this->apiResponse($response));
// get code and error message if any, assigned to vars $code and $error
if (isset($error) && $error !== false) {
if ($code == 401) {
$this->delete_transient($cache_key);
}
if ($level === 'equity' && $code == 401) {
$equity_401_message = 'Also confirm you are using the same domain as on your IDX Broker account.';
return new \WP_Error("idx_api_error", __("Error {$code}: {$error} {$equity_401_message}"));
}
return new \WP_Error("idx_api_error", __("Error {$code}: {$error}"));
} else {
$data = (array) json_decode((string) $response['body'], $json_decode_type);
if ($request_type !== 'POST') {
$this->set_transient($cache_key, $data, $expiration);
}
return $data;
}
}
开发者ID:jdelia,项目名称:wordpress-plugin,代码行数:46,代码来源:idx-api.php
示例17: mwform_admin_mail
/**
* @param $mail
* @param $data
* @return mixed
*/
public function mwform_admin_mail($mail, $data)
{
if (empty($this->option['api']) && empty($this->option['room'])) {
return $mail;
}
$mwwpform = get_post_meta($this->option['form'], 'mw-wp-form');
$subject = $mail->subject !== '' ? $mail->subject : __('メールを受信しました。', $this->mo);
$message[] = '===< Sender >=====================';
$message[] = $mail->sender . ' < ' . $mail->from . ' >' . PHP_EOL;
$message[] = '===< Body >=====================';
$message[] = $mail->body !== '' ? $mail->body : __('なし(管理者宛メール設定が未設定な可能性があります。)', $this->mo);
$message[] = '================================' . PHP_EOL;
if (isset($mwwpform[0]['usedb']) && (int) $mwwpform[0]['usedb'] === 1) {
$message[] = admin_url('/edit.php?post_type=mwf_' . $this->option['form']);
}
$message = sprintf('[info][title]%s[/title]%s[/info]', $subject, implode(PHP_EOL, $message));
$args = array('headers' => array('X-ChatWorkToken' => $this->option['api']), 'body' => array('body' => $message));
$remote = wp_safe_remote_post('https://api.chatwork.com/v1/rooms/' . $this->option['room'] . '/messages', $args);
return $mail;
}
开发者ID:kuck1u,项目名称:va-mw-wp-form-to-chatwork,代码行数:25,代码来源:class-send.php
示例18: validate_transaction
/**
* Validate a PDT transaction to ensure its authentic.
* @param string $transaction
* @return bool|array False or result array
*/
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;
}
// Parse transaction result data
$transaction_result = array_map('wc_clean', array_map('urldecode', explode("\n", $response['body'])));
$transaction_results = array();
foreach ($transaction_result as $line) {
$line = explode("=", $line);
$transaction_results[$line[0]] = isset($line[1]) ? $line[1] : '';
}
if (!empty($transaction_results['charset']) && function_exists('iconv')) {
foreach ($transaction_results as $key => $value) {
$transaction_results[$key] = iconv($transaction_results['charset'], 'utf-8', $value);
}
}
return $transaction_results;
}
开发者ID:tlovett1,项目名称:woocommerce,代码行数:27,代码来源:class-wc-gateway-paypal-pdt-handler.php
示例19: request
/**
* Send the request to Stripe's API
*
* @param array $request
* @param string $api
* @return array|WP_Error
*/
public static function request($request, $api = 'charges', $method = 'POST')
{
WC_Stripe::log("{$api} request: " . print_r($request, true));
$response = wp_safe_remote_post(self::ENDPOINT . $api, array('method' => $method, 'headers' => array('Authorization' => 'Basic ' . base64_encode(self::get_secret_key() . ':'), 'Stripe-Version' => '2016-03-07'), 'body' => apply_filters('woocommerce_stripe_request_body', $request, $api), 'timeout' => 70, 'user-agent' => 'WooCommerce ' . WC()->version));
if (is_wp_error($response) || empty($response['body'])) {
WC_Stripe::log("Error Response: " . print_r($response, true));
return new WP_Error('stripe_error', __('There was a problem connecting to the payment gateway.', 'woocommerce-gateway-stripe'));
}
$parsed_response = json_decode($response['body']);
// Handle response
if (!empty($parsed_response->error)) {
if (!empty($parsed_response->error->param)) {
$code = $parsed_response->error->param;
} elseif (!empty($parsed_response->error->code)) {
$code = $parsed_response->error->code;
} else {
$code = 'stripe_error';
}
return new WP_Error($code, $parsed_response->error->message);
} else {
return $parsed_response;
}
}
开发者ID:developmentDM2,项目名称:The-Haute-Mess,代码行数:30,代码来源:class-wc-stripe-api.php
示例20: validate_ipn
/**
* Check PayPal IPN validity
*/
public function validate_ipn()
{
WC_Gateway_Paypal::log('Checking IPN response is valid');
// Get received values from post data
$validate_ipn = array('cmd' => '_notify-validate');
$validate_ipn += wp_unslash($_POST);
// Send back post vars to paypal
$params = array('body' => $validate_ipn, 'timeout' => 60, 'httpversion' => '1.1', 'compress' => false, 'decompress' => false, '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', $params);
WC_Gateway_Paypal::log('IPN Request: ' . print_r($params, true));
WC_Gateway_Paypal::log('IPN Response: ' . print_r($response, true));
// check to see if the request was valid
if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 && strstr($response['body'], 'VERIFIED')) {
WC_Gateway_Paypal::log('Received valid response from PayPal');
return true;
}
WC_Gateway_Paypal::log('Received invalid response from PayPal');
if (is_wp_error($response)) {
WC_Gateway_Paypal::log('Error response: ' . $response->get_error_message());
}
return false;
}
开发者ID:abcode619,项目名称:wpstuff,代码行数:26,代码来源:class-wc-gateway-paypal-ipn-handler.php
注:本文中的wp_safe_remote_post函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论