本文整理汇总了PHP中wp_remote_post函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_remote_post函数的具体用法?PHP wp_remote_post怎么用?PHP wp_remote_post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_remote_post函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: gdrive_auth_token
public static function gdrive_auth_token()
{
if (isset($_GET['code'])) {
$post_vars = array('code' => $_GET['code'], 'client_id' => UpdraftPlus_Options::get_updraft_option('updraft_googledrive_clientid'), 'client_secret' => UpdraftPlus_Options::get_updraft_option('updraft_googledrive_secret'), 'redirect_uri' => admin_url('options-general.php?page=updraftplus&action=updraftmethod-googledrive-auth'), 'grant_type' => 'authorization_code');
$result = wp_remote_post('https://accounts.google.com/o/oauth2/token', array('timeout' => 30, 'method' => 'POST', 'body' => $post_vars));
if (is_wp_error($result)) {
$add_to_url = "Bad response when contacting Google: ";
foreach ($result->get_error_messages() as $message) {
global $updraftplus;
$updraftplus->log("Google Drive authentication error: " . $message);
$add_to_url .= "{$message}. ";
}
header('Location: ' . admin_url('options-general.php?page=updraftplus&error=' . urlencode($add_to_url)));
} else {
$json_values = json_decode($result['body'], true);
if (isset($json_values['refresh_token'])) {
// Save token
UpdraftPlus_Options::update_updraft_option('updraft_googledrive_token', $json_values['refresh_token']);
if (isset($json_values['access_token'])) {
set_transient('updraftplus_tmp_googledrive_access_token', $json_values['access_token'], 3600);
// We do this to clear the GET parameters, otherwise WordPress sticks them in the _wp_referer in the form and brings them back, leading to confusion + errors
header('Location: ' . admin_url('options-general.php?page=updraftplus&action=updraftmethod-googledrive-auth&state=success'));
}
} else {
$msg = __('No refresh token was received from Google. This often means that you entered your client secret wrongly, or that you have not yet re-authenticated (below) since correcting it. Re-check it, then follow the link to authenticate again. Finally, if that does not work, then use expert mode to wipe all your settings, create a new Google client ID/secret, and start again.', 'updraftplus');
if (isset($json_values['error'])) {
$msg .= ' ' . sprintf(__('Error: %s', 'updraftplus'), $json_values['error']);
}
header('Location: ' . admin_url('options-general.php?page=updraftplus&error=' . $msg));
}
}
} else {
header('Location: ' . admin_url('options-general.php?page=updraftplus&error=' . __('Authorization failed', 'updraftplus')));
}
}
开发者ID:brandmobility,项目名称:kikbak,代码行数:35,代码来源:googledrive.php
示例2: 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
示例3: check_for_update
function check_for_update($transient)
{
global $wp_filesystem, $smof_data;
if (empty($transient->checked)) {
return $transient;
}
$request_args = array('id' => $this->id, 'slug' => $this->slug, 'version' => $transient->checked[$this->id]);
$request_args['item_code'] = '2833226';
$request_args['envato_username'] = $smof_data['t4p_username'];
$request_args['api_key'] = $smof_data['t4p_api'];
$filename = trailingslashit(get_template_directory()) . 'log.txt';
$request_string = $this->prepare_request('plugin_update', $request_args);
$raw_response = wp_remote_post($this->api_url, $request_string);
$response = null;
if (!is_wp_error($raw_response) && $raw_response['response']['code'] == 200) {
$response = json_decode($raw_response['body'], true);
}
if (!empty($response)) {
// Feed the update data into WP updater
$transient->response[$this->id] = (object) $response;
}
/*$handle = fopen($filename, 'a');
fwrite($handle, json_encode($request_string));
fwrite($handle, json_encode($raw_response));*/
return $transient;
}
开发者ID:berniecultess,项目名称:infirev,代码行数:26,代码来源:class-updater.php
示例4: layerslider_verify_purchase_code
function layerslider_verify_purchase_code()
{
global $wp_version;
// Get data
$pcode = get_option('layerslider-purchase-code', '');
$validated = get_option('layerslider-validated', '0');
$channel = $_POST['channel'] === 'beta' ? 'beta' : 'stable';
// Save sent data
update_option('layerslider-release-channel', $channel);
update_option('layerslider-purchase-code', $_POST['purchase_code']);
// Release channel
if ($validated == 1) {
if ($pcode == $_POST['purchase_code']) {
die(json_encode(array('success' => true, 'message' => __('Your settings were successfully saved.', 'LayerSlider'))));
}
}
// Verify license
$response = wp_remote_post('http://activate.kreaturamedia.com/', array('user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url'), 'body' => array('plugin' => urlencode('LayerSlider WP'), 'license' => urlencode($_POST['purchase_code']))));
// Valid
if ($response['body'] == 'valid') {
update_option('layerslider-validated', '1');
die(json_encode(array('success' => true, 'message' => __('Thank you for purchasing LayerSlider WP. You successfully validated your purchase code for auto-updates.', 'LayerSlider'))));
// Invalid
} else {
update_option('layerslider-validated', '0');
die(json_encode(array('success' => false, 'message' => __("Your purchase code doesn't appear to be valid. Please make sure that you entered your purchase code correctly.", "LayerSlider"))));
}
}
开发者ID:scottnkerr,项目名称:eeco,代码行数:28,代码来源:layerslider.php
示例5: mm_ux_log
function mm_ux_log($args = array())
{
$url = "https://ssl.google-analytics.com/collect";
global $title;
if (empty($_SERVER['REQUEST_URI'])) {
return;
}
$path = explode('wp-admin', $_SERVER['REQUEST_URI']);
if (empty($path) || empty($path[1])) {
$path = array("", " ");
}
$defaults = array('v' => '1', 'tid' => 'UA-39246514-3', 't' => 'pageview', 'cid' => md5(get_option('siteurl')), 'uid' => md5(get_option('siteurl') . get_current_user_id()), 'cn' => 'mojo_wp_plugin', 'cs' => 'mojo_wp_plugin', 'cm' => 'plugin_admin', 'ul' => get_locale(), 'dp' => $path[1], 'sc' => '', 'ua' => @$_SERVER['HTTP_USER_AGENT'], 'dl' => $path[1], 'dh' => get_option('siteurl'), 'dt' => $title, 'ec' => '', 'ea' => '', 'el' => '', 'ev' => '');
if (isset($_SERVER['REMOTE_ADDR'])) {
$defaults['uip'] = $_SERVER['REMOTE_ADDR'];
}
$params = wp_parse_args($args, $defaults);
$test = get_transient('mm_test', '');
if (isset($test['key']) && isset($test['name'])) {
$params['cm'] = $params['cm'] . "_" . $test['name'] . "_" . $test['key'];
}
//use test account for testing
if (defined('WP_DEBUG') && WP_DEBUG) {
$params['tid'] = 'UA-19617272-27';
}
$z = wp_rand(0, 1000000000);
$query = http_build_query(array_filter($params));
$args = array('body' => $query, 'method' => 'POST', 'blocking' => false);
$url = add_query_arg(array('z' => $z), $url);
wp_remote_post($url, $args);
}
开发者ID:hyperhy,项目名称:hyperhy,代码行数:30,代码来源:user-experience-tracking.php
示例6: pmxi_wp_ajax_save_import_functions
function pmxi_wp_ajax_save_import_functions()
{
if (!check_ajax_referer('wp_all_import_secure', 'security', false)) {
exit(json_encode(array('html' => __('Security check', 'wp_all_import_plugin'))));
}
if (!current_user_can('manage_options')) {
exit(json_encode(array('html' => __('Security check', 'wp_all_import_plugin'))));
}
$uploads = wp_upload_dir();
$functions = $uploads['basedir'] . DIRECTORY_SEPARATOR . WP_ALL_IMPORT_UPLOADS_BASE_DIRECTORY . DIRECTORY_SEPARATOR . 'functions.php';
$input = new PMXI_Input();
$post = $input->post('data', '');
$response = wp_remote_post('http://phpcodechecker.com/api', array('body' => array('code' => $post)));
if (is_wp_error($response)) {
$error_message = $response->get_error_message();
exit(json_encode(array('result' => false, 'msg' => $error_message)));
die;
} else {
$body = json_decode(wp_remote_retrieve_body($response), true);
if ($body['errors'] === 'TRUE') {
exit(json_encode(array('result' => false, 'msg' => $body['syntax']['message'])));
die;
} elseif ($body['errors'] === 'FALSE') {
if (strpos($post, "<?php") === false || strpos($post, "?>") === false) {
exit(json_encode(array('result' => false, 'msg' => __('PHP code must be wrapped in "<?php" and "?>"', 'wp_all_import_plugin'))));
die;
} else {
file_put_contents($functions, $post);
}
}
}
exit(json_encode(array('result' => true, 'msg' => __('File has been successfully updated.', 'wp_all_import_plugin'))));
die;
}
开发者ID:lizbur10,项目名称:js_finalproject,代码行数:34,代码来源:wp_ajax_save_import_functions.php
示例7: fetch
/**
* Execute an API call
* @param string $method The HTTP method
* @param string $url The API endpoint
* @param string $call The API method to call
* @param array $additional Additional parameters
* @return array
*/
public function fetch($method, $url, $call, array $additional = array())
{
// Get the signed request URL
$request = $this->getSignedRequest($method, $url, $call, $additional);
if ($method == 'GET') {
$args = array();
$response = wp_remote_get($request['url'], $args);
$this->outFile = null;
} elseif ($method == 'POST') {
$args = array('body' => $request['postfields']);
$response = wp_remote_post($request['url'], $args);
} elseif ($method == 'PUT' && $this->inFile) {
return new WP_Error('unsupported', "WordPress does not have a native HTTP PUT function");
}
// If the response body is not a JSON encoded string
// we'll return the entire response body
// Important to do this first, as the next section relies on the decoding having taken place
if (!($body = json_decode($response['body']))) {
$body = $response['body'];
}
// Check if an error occurred and throw an Exception. This is part of the authentication process - don't modify.
if (!empty($body->error)) {
$message = $body->error . ' (Status Code: ' . $response['code'] . ')';
throw new Dropbox_Exception($message);
}
if (is_wp_error($response)) {
$message = $response->get_error_message();
throw new Dropbox_Exception($message);
}
$results = array('body' => $body, 'code' => $response['response']['code'], 'headers' => $response['headers']);
return $results;
}
开发者ID:santikrass,项目名称:apache,代码行数:40,代码来源:WordPress.php
示例8: 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 e-Commerce/' . WPSC_PRESENTABLE_VERSION);
$response = wp_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:dreamteam111,项目名称:dreamteam,代码行数:32,代码来源:paypal-express.merchant.php
示例9: 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
* overridding 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 mixed
*/
function plugins_api($action, $args = null)
{
if (is_array($args)) {
$args = (object) $args;
}
if (!isset($args->per_page)) {
$args->per_page = 24;
}
$args = apply_filters('plugins_api_args', $args, $action);
//NOTE: Ensure that an object is returned via this filter.
$res = apply_filters('plugins_api', false, $action, $args);
//NOTE: Allows a plugin to completely override the builtin WordPress.org API.
if (!$res) {
$request = wp_remote_post('http://api.wordpress.org/plugins/info/1.0/', array('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.</p> <p><a href="?" onclick="document.location.reload(); return false;">Try again</a>'), $request->get_error_message());
} else {
$res = unserialize($request['body']);
if (!$res) {
$res = new WP_Error('plugins_api_failed', __('An unknown error occurred'), $request['body']);
}
}
}
return apply_filters('plugins_api_result', $res, $action, $args);
}
开发者ID:schr,项目名称:wordpress,代码行数:45,代码来源:plugin-install.php
示例10: 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
示例11: doRequests
public function doRequests($URLs, $Blocking, $ID)
{
$requestParameters = array('plugin_version' => PLUGIN_VERSION, 'key' => $this->_apiKey, 'lossy' => $this->_compressionType, 'cmyk2rgb' => $this->_CMYKtoRGBconversion, 'resize' => $this->_resizeImages, 'resize_width' => $this->_resizeWidth, 'resize_height' => $this->_resizeHeight, 'urllist' => $URLs);
$arguments = array('method' => 'POST', 'timeout' => 45, 'redirection' => 3, 'sslverify' => false, 'httpversion' => '1.0', 'blocking' => $Blocking, 'headers' => array(), 'body' => json_encode($requestParameters), 'cookies' => array());
$response = wp_remote_post($this->_apiEndPoint, $arguments);
//only if $Blocking is true analyze the response
if ($Blocking) {
//there was an error, save this error inside file's SP optimization field
if (is_object($response) && get_class($response) == 'WP_Error') {
$errorMessage = $response->errors['http_request_failed'][0];
$errorCode = 503;
} elseif (isset($response['response']['code']) && $response['response']['code'] != 200) {
$errorMessage = $response['response']['code'] . " - " . $response['response']['message'];
$errorCode = $response['response']['code'];
}
if (isset($errorMessage)) {
//set details inside file so user can know what happened
$meta = wp_get_attachment_metadata($ID);
$meta['ShortPixelImprovement'] = 'Error: <i>' . $errorMessage . '</i>';
unset($meta['ShortPixel']['WaitingProcessing']);
wp_update_attachment_metadata($ID, $meta);
return array("response" => array("code" => $errorCode, "message" => $errorMessage));
}
return $response;
//this can be an error or a good response
}
return $response;
}
开发者ID:evandrewry,项目名称:maiaflow,代码行数:28,代码来源:shortpixel_api.php
示例12: check_for_update
function check_for_update($transient)
{
global $wp_filesystem;
$avada_options = get_option('Avada_Key');
if (empty($transient->checked)) {
return $transient;
}
$request_args = array('id' => $this->theme_id, 'slug' => $this->theme_slug, 'version' => $transient->checked[$this->theme_slug]);
if ($this->api_url == 'http://updates.theme-fusion.com/avada-theme.php') {
$request_args['item_code'] = '2833226';
$request_args['envato_username'] = $avada_options['tf_username'];
$request_args['api_key'] = $avada_options['tf_api'];
}
$filename = trailingslashit(get_template_directory()) . 'log.txt';
$request_string = $this->prepare_request('theme_update', $request_args);
$raw_response = wp_remote_post($this->api_url, $request_string);
$response = null;
if (!is_wp_error($raw_response) && $raw_response['response']['code'] == 200) {
$response = json_decode($raw_response['body'], true);
}
if (!empty($response)) {
// Feed the update data into WP updater
$transient->response[$this->theme_slug] = $response;
}
/*$handle = fopen($filename, 'a');
fwrite($handle, json_encode($request_string));
fwrite($handle, json_encode($raw_response));*/
return $transient;
}
开发者ID:rvelezc,项目名称:drpelaezgo.com,代码行数:29,代码来源:class-avada-theme-updater.php
示例13: 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
示例14: call
public function call($operation, $params = array())
{
$url = self::URL . '/' . $operation;
$params['blog'] = $this->blog;
if ($this->ready()) {
$params['token'] = $this->token;
}
$response = wp_remote_post($url, array('body' => $params, 'timeout' => 0));
if (is_wp_error($response)) {
die($response->get_error_message());
}
$response = json_decode($response['body']);
if (property_exists($response, 'error')) {
if (is_object($response->error)) {
die($response->error->message);
} elseif ($response->code == 'invalid-session') {
throw new ClientInvalidSession();
} else {
die($response->error);
}
}
if (property_exists($response, 'token')) {
update_option(self::TOKEN, $response->token);
}
return $response;
}
开发者ID:annbransom,项目名称:techishowl_prod_backup,代码行数:26,代码来源:client.php
示例15: validate_themes
protected function validate_themes()
{
if (empty($this->themes) || !is_array($this->themes)) {
return new WP_Error('missing_themes', __('No themes found.', 'jetpack'));
}
foreach ($this->themes as $index => $theme) {
if (self::is_installed_theme($theme)) {
return new WP_Error('theme_already_installed', __('The theme is already installed', 'jetpack'));
}
if (wp_endswith($theme, '-wpcom')) {
$file = self::download_wpcom_theme_to_file($theme);
if (is_wp_error($file)) {
return $file;
}
$this->download_links[$theme] = $file;
continue;
}
$params = (object) array('slug' => $theme);
$url = 'https://api.wordpress.org/themes/info/1.0/';
$args = array('body' => array('action' => 'theme_information', 'request' => serialize($params)));
$response = wp_remote_post($url, $args);
$theme_data = unserialize($response['body']);
if (is_wp_error($theme_data)) {
return $theme_data;
}
if (!is_object($theme_data) && !isset($theme_data->download_link)) {
return new WP_Error('theme_not_found', __('This theme does not exist', 'jetpack'), 404);
}
$this->download_links[$theme] = $theme_data->download_link;
}
return true;
}
开发者ID:netmagik,项目名称:netmagik,代码行数:32,代码来源:class.jetpack-json-api-themes-install-endpoint.php
示例16: dynamik_update_check
/**
* Check to see if a new version of Catayst is available.
*
* @since 1.0
* @return either response or transient.
*/
function dynamik_update_check()
{
global $wp_version;
// Debug Auto-Update.
//delete_transient( 'dynamik-gen-update' );
$dynamik_transient = get_transient('dynamik-gen-update');
if ($dynamik_transient == false) {
$api_url = 'http://api.cobaltapps.com/dynamik-update/';
// Start checking for an update
$send_for_check = array('body' => array('action' => 'theme_update', 'request' => array('slug' => 'dynamik-gen', 'version' => CHILD_THEME_VERSION)), 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url());
$raw_response = wp_remote_post($api_url, $send_for_check);
if (!is_wp_error($raw_response) && $raw_response['response']['code'] == 200 && is_serialized($raw_response['body'])) {
$response = unserialize($raw_response['body']);
} else {
set_transient('dynamik-gen-update', array('new_version' => CHILD_THEME_VERSION), 60 * 60 * 24);
// store for 24 hours
}
if (!empty($response)) {
set_transient('dynamik-gen-update', $response, 60 * 60 * 24);
// store for 24 hours
return $response;
}
} else {
return $dynamik_transient;
}
}
开发者ID:kabrewer07,项目名称:mrw,代码行数:32,代码来源:dynamik-update.php
示例17: apiRequest
private static function apiRequest($act, $post_data = null, $use_ssl = true)
{
global $wp_version;
$site = rawurlencode(base64_encode(get_option('siteurl')));
$url = "http" . ($use_ssl ? "s://ssl-account.com" : ":/") . "/interface.fabi.me/wpfilebase-pro/{$act}.php";
$get_args = array('version' => WPFB_VERSION, 'pl_slug' => 'wp-filebase', 'pl_ver' => WPFB_VERSION, 'wp_ver' => $wp_version, 'site' => $site);
// try to get from cache
$cache_key = 'wpfb_apireq_' . md5($act . '||' . serialize($get_args) . '||' . serialize($post_data) . '||' . __FILE__);
if (isset($_REQUEST['no_api_cache'])) {
delete_transient($cache_key);
}
$res = get_transient($cache_key);
if ($res !== false) {
return $res;
}
//trigger_error ( "WP-Filebase apiRequest (ssl=$use_ssl): $act ".json_encode($post_data), E_USER_NOTICE );
if (empty($post_data)) {
$res = wp_remote_get($url, $get_args);
} else {
$res = wp_remote_post(add_query_arg($get_args, $url), array('body' => $post_data));
}
if (is_wp_error($res)) {
if ($use_ssl) {
// retry without ssl
return self::apiRequest($act, $post_data, false);
}
echo "<b>WP-Filebase API request error:</b>";
print_r($res);
return false;
}
$res = empty($res['body']) ? false : json_decode($res['body']);
set_transient($cache_key, $res, 0 + 6 * HOUR_IN_SECONDS);
return $res;
}
开发者ID:TishoTM,项目名称:WP-Filebase,代码行数:34,代码来源:ExtensionLib.php
示例18: process_access_token_request
protected function process_access_token_request()
{
if (array_key_exists('code', $_REQUEST) && array_key_exists('post_id', $_REQUEST)) {
global $pms_post_protected;
global $pms_session;
$post_id = intval($_REQUEST['post_id']);
$settings = $this->get_settings();
$url = Postmatic_Social_Gplus_Authenticator::$ACCESS_URL;
$client_id = $settings[Postmatic_Social_Gplus_Authenticator::$CLIENT_ID];
$client_secret = $settings[Postmatic_Social_Gplus_Authenticator::$CLIENT_SECRET];
$query_string = $this->to_query_string(array('code' => $_REQUEST['code'], 'client_id' => $client_id, 'client_secret' => $client_secret, 'redirect_uri' => $this->get_oauth_callback(), 'grant_type' => 'authorization_code'));
$response = wp_remote_post(esc_url_raw($url), array('body' => $query_string, 'sslverify' => false));
if (is_wp_error($response)) {
$error_string = $response->get_error_message();
throw new Exception($error_string);
} else {
$response_body = json_decode($response['body'], true);
if ($response_body && is_array($response_body) && array_key_exists('access_token', $response_body)) {
$access_token = $response_body['access_token'];
$user_details = $this->get_user_details($access_token);
$pms_session['user'] = $user_details;
$pms_post_protected = true;
$user_details['disconnect_content'] = $GLOBALS['postmatic-social']->disconnect_content($user_details, $post_id);
wp_send_json($user_details);
die;
} else {
throw new Exception(__('Missing the access_token parameter', 'postmatic-social'));
}
}
} else {
die;
}
}
开发者ID:johnpuddephatt,项目名称:postmatic-social,代码行数:33,代码来源:Postmatic_Social_Gplus_Authenticator.php
示例19: check_for_update
/**
* Check the server for theme updates.
*
* @param object $data `update_themes` transient
* @return object Transformed `update_themes` transient
*/
public static function check_for_update($data)
{
// Setup
self::set_theme_data();
$request = array('slug' => self::$theme_slug, 'version' => self::$theme_version);
if (defined('DOING_CRON') && DOING_CRON) {
$timeout = 30;
} else {
$timeout = 3;
}
$options = array('timeout' => $timeout, 'body' => array('request' => wp_json_encode($request)));
$raw_response = wp_remote_post(self::$api_url, $options);
if (is_wp_error($raw_response)) {
return $raw_response;
} else {
if (wp_remote_retrieve_response_code($raw_response) !== 200) {
return new WP_Error('broke', __('Theme update failed:'), $raw_response);
}
}
$response = json_decode(wp_remote_retrieve_body($raw_response), true);
if (gettype($response) === 'array' && isset($response['new_version']) && isset($response['url']) && isset($response['package'])) {
$data->response[self::$theme_slug] = array('theme' => self::$theme_slug, 'new_version' => $response['new_version'], 'url' => $response['url'], 'package' => $response['package']);
}
return $data;
}
开发者ID:pemiu01,项目名称:sc-theme-update,代码行数:31,代码来源:class-sc-theme-updater-client.php
示例20: add
/**
* Submit customer report to ServMask.com
*
* @param string $email User E-mail
* @param string $message User Message
* @param integer $terms User Accept Terms
*
* @return array
*/
public function add( $email, $message, $terms ) {
$errors = array();
// Submit report to ServMask
if ( ! filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
$errors[] = __( 'Your email is not valid.', AI1WM_PLUGIN_NAME );
} else if ( empty( $message ) ) {
$errors[] = __( 'Please enter comments in the text area.', AI1WM_PLUGIN_NAME );
} else if ( empty( $terms ) ) {
$errors[] = __( 'Please accept report term conditions.', AI1WM_PLUGIN_NAME );
} else {
$response = wp_remote_post(
AI1WM_REPORT_URL,
array(
'body' => array(
'email' => $email,
'message' => $message,
),
)
);
if ( is_wp_error( $response ) ) {
$errors[] = sprintf( __( 'Something went wrong: %s', AI1WM_PLUGIN_NAME ), $response->get_error_message() );
}
}
return array( 'errors' => $errors );
}
开发者ID:jknowles94,项目名称:Work-examples,代码行数:37,代码来源:class-ai1wm-report.php
注:本文中的wp_remote_post函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论