本文整理汇总了PHP中wp_remote_retrieve_response_message函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_remote_retrieve_response_message函数的具体用法?PHP wp_remote_retrieve_response_message怎么用?PHP wp_remote_retrieve_response_message使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_remote_retrieve_response_message函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_api_response
/**
* Request data from the thir party API.
*
* @since 1.5.4
* @param string $base_url Base URL where API is available
* @param string $api_key API Key provided by this service
* @param string $endpoint Method to request available from this service.
* @param array $params Data to be passed to API
* @return array|object The API response.
*/
private function get_api_response($base_url, $api_key, $endpoint, $params = array())
{
// Exclude http:// from the user's input
$request_uri = $this->api_protocol . '://' . preg_replace('#^https?://#', '', $base_url) . '/api/v' . $this->api_version . $endpoint;
$params['timeout'] = 60;
$params['body'] = isset($params['data']) && $params['data'] ? json_encode($params['data']) : '';
$params['headers'] = array('Authorization' => 'TRUEREST apikey=' . $api_key);
$response = wp_remote_get($request_uri, $params);
$response_code = wp_remote_retrieve_response_code($response);
$response_message = wp_remote_retrieve_response_message($response);
$get_response = json_decode(wp_remote_retrieve_body($response), true);
if (is_wp_error($response) || 200 != $response_code) {
if (is_wp_error($response)) {
$data['error'] = $response->get_error_message();
} else {
$data['error'] = isset($get_response['msg']) ? $get_response['msg'] : $response_code . ' - ' . $response_message;
}
} else {
if ($get_response) {
$data = $get_response;
} else {
$data = $response;
}
}
return $data;
}
示例2: remote_request
/**
* Send the api request to Brickset. Returns an XML formatted response.
*
* @author Nate Jacobs
* @since 0.1
* @updated 1.0
*
* @param string url needed after base url
* @param string query parameters
*
* @return object WP_Error
* @return array
*/
protected function remote_request($type, $extra_url, $params = '')
{
$api_url = 'http://www.brickset.com/webservices/brickset.asmx';
if ('get' == $type) {
//wp_die( $api_url.'/'.$extra_url.'?'.$params );
$response = wp_remote_get($api_url . '/' . $extra_url . '?' . $params);
} elseif ('post' == $type) {
$response = wp_remote_post($api_url . '/' . $extra_url, $params);
} else {
return new WP_Error('no-type-specified', __('Specify a type of request: get or post', 'bs_api'));
}
// Did the HTTP request fail?
if (is_wp_error($response)) {
return $response;
}
$response_code = wp_remote_retrieve_response_code($response);
$response_message = wp_remote_retrieve_response_message($response);
$response_body = wp_remote_retrieve_body($response);
if (200 != $response_code && !empty($response_message)) {
return new WP_Error($response_code, __('Don\'t Panic! Something went wrong and Brickset didn\'t reply.', 'bs_api'));
} elseif (200 != $response_code) {
return new WP_Error($response_code, __('Unknown error occurred', 'bs_api'));
} elseif ($extra_url != 'login' && 300 > strlen($response_body) && $type == 'get') {
return new WP_Error('brickset-no-data', __('Sorry, no sets were found for that query', 'bs_api'));
} else {
return $response_body;
}
}
示例3: uploadFile
static function uploadFile($file_url, $path, $file_name)
{
$file_name = sanitize_file_name($file_name);
$full_file_name = $path . DIRECTORY_SEPARATOR . $file_name;
//Local name
$response = wp_remote_get($file_url, array('timeout' => 10 * 60 * 60, 'stream' => true, 'filename' => $full_file_name));
if (is_wp_error($response)) {
@unlink($full_file_name);
throw new Exception('Error: ' . $response->get_error_message());
}
if (200 != wp_remote_retrieve_response_code($response)) {
@unlink($full_file_name);
throw new Exception('Error 404: ' . trim(wp_remote_retrieve_response_message($response)));
}
if (substr($file_name, -12) == ".phpfile.txt") {
$new_file_name = substr($file_name, 0, -12) . ".php";
$new_file_name = $path . DIRECTORY_SEPARATOR . $new_file_name;
$moved = @rename($full_file_name, $new_file_name);
if ($moved) {
return array('path' => $new_file_name);
} else {
@unlink($full_file_name);
throw new Exception('Error: Copy file.');
}
}
return array('path' => $full_file_name);
}
示例4: smart_manager_validate_license_key
function smart_manager_validate_license_key()
{
global $sm_base_name, $sm_check_update_timeout, $sm_plugin_data, $sm_sku, $sm_license_key, $sm_download_url, $sm_installed_version, $sm_live_version;
$sm_license_key = isset($_REQUEST['license_key']) && !empty($_REQUEST['license_key']) ? $_REQUEST['license_key'] : '';
$storeapps_validation_url = 'http://www.storeapps.org/wp-admin/admin-ajax.php?action=woocommerce_validate_serial_key&serial=' . urlencode($sm_license_key) . '&is_download=true&sku=' . $sm_sku;
$resp_type = array('headers' => array('content-type' => 'application/text'));
$response_info = wp_remote_post($storeapps_validation_url, $resp_type);
//return WP_Error on response failure
if (is_array($response_info)) {
$response_code = wp_remote_retrieve_response_code($response_info);
$response_msg = wp_remote_retrieve_response_message($response_info);
// if ($response_code == 200 && $response_msg == 'OK') {
if ($response_code == 200) {
$storeapps_response = wp_remote_retrieve_body($response_info);
$decoded_response = json_decode($storeapps_response);
if ($decoded_response->is_valid == 1) {
update_site_option('smart_manager_license_key', $sm_license_key);
update_site_option('smart_manager_download_url', $decoded_response->download_url);
} else {
remove_license_download_url();
}
echo $storeapps_response;
exit;
}
remove_license_download_url();
echo json_encode(array('is_valid' => 0));
exit;
}
remove_license_download_url();
echo json_encode(array('is_valid' => 0));
exit;
}
示例5: check_email
public function check_email($data = '')
{
if (empty($this->public_key)) {
return new WP_Error('no_api_key', __('No API key was provided', 'awesome-support'));
}
if (empty($data)) {
if (isset($_POST)) {
$data = $_POST;
} else {
return new WP_Error('no_data', __('No data to check', 'awesome-support'));
}
}
if (!isset($data['email'])) {
return new WP_Error('no_email', __('No e-mail to check', 'awesome-support'));
}
global $wp_version;
$args = array('timeout' => 5, 'redirection' => 5, 'httpversion' => '1.0', 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url'), 'blocking' => true, 'headers' => array('Authorization' => 'Basic ' . base64_encode('api:' . $this->public_key)), 'cookies' => array(), 'body' => array('address' => $data['email']), 'compress' => false, 'decompress' => true, 'sslverify' => true, 'stream' => false, 'filename' => null);
$response = wp_remote_get(esc_url($this->endpoint), $args);
$response_code = wp_remote_retrieve_response_code($response);
if (is_wp_error($response)) {
return $response;
}
if (200 != $response_code) {
return new WP_Error($response_code, wp_remote_retrieve_response_message($response));
}
$body = wp_remote_retrieve_body($response);
return $body;
}
示例6: wclv_get_repos
function wclv_get_repos($username)
{
$response = wp_remote_get("https://api.github.com/users/{$username}/repos");
if ('200' != wp_remote_retrieve_response_code($response)) {
return wp_remote_retrieve_response_message($response);
}
// Error retrieving repos
$body = wp_remote_retrieve_body($response);
$body = json_decode($body);
return $body;
}
示例7: callAPI
function callAPI($url)
{
// FIXME set timeout, useragent, etc.
$api_response = wp_remote_get($url);
$rsp_code = wp_remote_retrieve_response_code($api_response);
$rsp_msg = wp_remote_retrieve_response_message($api_response);
$rsp_body = wp_remote_retrieve_body($api_response);
// If request wasn't successfull return error.
if ($rsp_code != 200) {
return new WP_ERROR('api_call_failed', "Failed calling " . $url, $rsp_msg);
}
return new APIResponse($rsp_body);
}
示例8: countryCode
function countryCode($ip = '')
{
if (!$ip) {
$ip = $_SERVER['REMOTE_ADDR'];
}
$response = @wp_remote_get("http://ipinfo.io/" . $ip . "/json");
if (200 == wp_remote_retrieve_response_code($response) && 'OK' == wp_remote_retrieve_response_message($response) && !is_wp_error($response)) {
$data = json_decode($response['body'], 1);
return $data['country'];
//code
}
return false;
}
示例9: makeRequest
public function makeRequest($method, $url, $params = null)
{
$method = strtolower($method);
$headers = self::getHeaders();
$credentials = Config::getCredentials();
if (empty($credentials) || empty($credentials['login']) || empty($credentials['apiToken'])) {
throw new ApiException("Authorization error. Please ensure your login and API Token credentials are correct.");
}
$headers['Authorization'] = 'Basic ' . base64_encode($credentials['login'] . ':' . $credentials['apiToken']);
$opts = array('timeout' => Config::DEFAULT_REQUEST_TIMEOUT, 'headers' => $headers);
switch ($method) {
case 'get':
if (count($params) > 0) {
$url = "{$url}?" . http_build_query($params, null, '&');
}
$response = wp_remote_get($url, $opts);
break;
case 'post':
$opts['body'] = json_encode($params);
$response = wp_remote_post($url, $opts);
break;
case 'delete':
$opts['method'] = 'DELETE';
if (count($params) > 0) {
$url = "{$url}?" . http_build_query($params, null, '&');
}
$response = wp_remote_request($url, $opts);
break;
case 'put':
$opts['method'] = 'PUT';
$opts['body'] = json_encode($params);
$response = wp_remote_request($url, $opts);
break;
default:
throw new ApiException("Unrecognized API Method: {$method}");
}
$response_code = wp_remote_retrieve_response_code($response);
if ($response_code < 200 || $response_code >= 300) {
$message = wp_remote_retrieve_response_message($response);
if (empty($message)) {
$message = "API Error ({$httpCode})";
}
throw new ApiException($message, $response_code);
}
try {
$result = json_decode(wp_remote_retrieve_body($response), true);
} catch (Exception $e) {
throw new ApiException("Invalid API Response: " . wp_remote_retrieve_body($response), $response_code);
}
return $result;
}
示例10: process_signup
/**
* Process registration
*
* @since 2.1
*/
public function process_signup()
{
global $rcp_options;
$args = array('USER' => $this->username, 'PWD' => $this->password, 'SIGNATURE' => $this->signature, 'VERSION' => '124', 'METHOD' => $this->auto_renew ? 'CreateRecurringPaymentsProfile' : 'DoDirectPayment', 'AMT' => $this->amount, 'CURRENCYCODE' => strtoupper($this->currency), 'SHIPPINGAMT' => 0, 'TAXAMT' => 0, 'DESC' => $this->subscription_name, 'SOFTDESCRIPTOR' => get_bloginfo('name') . ' - ' . $this->subscription_name, 'SOFTDESCRIPTORCITY' => get_bloginfo('admin_email'), 'CUSTOM' => $this->user_id, 'NOTIFYURL' => add_query_arg('listener', 'EIPN', home_url('index.php')), 'EMAIL' => $this->email, 'CREDITCARDTYPE' => '', 'ACCT' => sanitize_text_field($_POST['rcp_card_number']), 'EXPDATE' => sanitize_text_field($_POST['rcp_card_exp_month'] . $_POST['rcp_card_exp_year']), 'CVV2' => sanitize_text_field($_POST['rcp_card_cvc']), 'ZIP' => sanitize_text_field($_POST['rcp_card_zip']), 'BUTTONSOURCE' => 'EasyDigitalDownloads_SP', 'PROFILESTARTDATE' => date('Y-m-d\\TH:i:s', strtotime('+' . $this->length . ' ' . $this->length_unit, time())), 'BILLINGPERIOD' => ucwords($this->length_unit), 'BILLINGFREQUENCY' => $this->length, 'FAILEDINITAMTACTION' => 'CancelOnFailure', 'TOTALBILLINGCYCLES' => $this->auto_renew ? 0 : 1);
if ($this->auto_renew) {
$initamt = round($this->amount + $this->signup_fee, 2);
if ($initamt >= 0) {
$args['INITAMT'] = $initamt;
}
}
$request = wp_remote_post($this->api_endpoint, array('timeout' => 45, 'sslverify' => false, 'httpversion' => '1.1', 'body' => $args));
$body = wp_remote_retrieve_body($request);
$code = wp_remote_retrieve_response_code($request);
$message = wp_remote_retrieve_response_message($request);
if (is_wp_error($request)) {
do_action('rcp_paypal_pro_signup_payment_failed', $request, $this);
$error = '<p>' . __('An unidentified error occurred.', 'rcp') . '</p>';
$error .= '<p>' . $request->get_error_message() . '</p>';
wp_die($error, __('Error', 'rcp'), array('response' => '401'));
} elseif (200 == $code && 'OK' == $message) {
if (is_string($body)) {
wp_parse_str($body, $body);
}
if (false !== strpos(strtolower($body['ACK']), 'failure')) {
do_action('rcp_paypal_pro_signup_payment_failed', $request, $this);
$error = '<p>' . __('PayPal subscription creation failed.', 'rcp') . '</p>';
$error .= '<p>' . __('Error message:', 'rcp') . ' ' . $body['L_LONGMESSAGE0'] . '</p>';
$error .= '<p>' . __('Error code:', 'rcp') . ' ' . $body['L_ERRORCODE0'] . '</p>';
wp_die($error, __('Error', 'rcp'), array('response' => '401'));
} else {
// Successful signup
$member = new RCP_Member($this->user_id);
if ($member->just_upgraded() && rcp_can_member_cancel($member->ID)) {
$cancelled = rcp_cancel_member_payment_profile($member->ID, false);
}
if (isset($body['PROFILEID'])) {
$member->set_payment_profile_id($body['PROFILEID']);
}
if (isset($body['PROFILESTATUS']) && 'ActiveProfile' === $body['PROFILESTATUS']) {
// Confirm a one-time payment
$member->renew($this->auto_renew);
}
wp_redirect(esc_url_raw(rcp_get_return_url()));
exit;
exit;
}
} else {
wp_die(__('Something has gone wrong, please try again', 'rcp'), __('Error', 'rcp'), array('back_link' => true, 'response' => '401'));
}
}
开发者ID:restrictcontentpro,项目名称:restrict-content-pro,代码行数:55,代码来源:class-rcp-payment-gateway-paypal-pro.php
示例11: validate_raw_response
/**
* @param object $response
* @return boolean
*/
private function validate_raw_response($response)
{
// make sure response came back okay
if (is_wp_error($response)) {
$this->error_message = $response->get_error_message();
return false;
}
// check response code, should be 200
$response_code = wp_remote_retrieve_response_code($response);
if (false === strstr($response_code, '200')) {
$response_message = wp_remote_retrieve_response_message($response);
$this->error_message = "{$response_code} {$response_message}";
return false;
}
return true;
}
示例12: call_http
function call_http()
{
// if submit button clicked, make the call
if (isset($_POST['call-submitted'])) {
// sanitize form values
$name = sanitize_text_field($_POST["call-name"]);
$email = sanitize_email($_POST["call-email"]);
$application = sanitize_text_field($_POST["call-application"]);
$password = sanitize_text_field($_POST["http-password"]);
// UCD test site
// $url = 'https://rtpucd01-srv.tivlab.raleigh.ibm.com:8443/cli/application/';
// vLaunch test site
$url = 'https://vlaunch.rtp.raleigh.ibm.com/groups';
// vLaunch create VM
// $url = 'https://vlaunch.rtp.raleigh.ibm.com/newrequests/RTP/1/createVM';
$args = array('headers' => array('Authorization' => 'Basic ' . base64_encode($name . ':' . $password)), 'sslverify' => false);
// end arg definition
$response = wp_remote_get($url, $args);
$msg = wp_remote_retrieve_response_message($response);
// If not empty, display message
if (!empty($msg)) {
echo 'Message: <pre>';
print_r($msg);
echo '</pre>';
}
$http_code = wp_remote_retrieve_response_code($response);
if (!empty($http_code)) {
echo 'Code: <pre>';
print_r($http_code);
echo '</pre>';
}
// Display result
if ($http_code == '200') {
echo '<p>Success!</p>';
} else {
echo '<p>An unexpected error occurred</p>';
}
echo 'Response: <pre>';
print_r($response);
// var_dump ($response);
echo '</pre>';
$body = wp_remote_retrieve_body($response);
echo '<p>Body:' . $body . '</p>';
}
// end isset($_POST['call-submitted'])
}
示例13: test
/**
* Test the WP Cron spawning system and report back its status.
*
* This command tests the spawning system by performing the following steps:
*
* * Checks to see if the `DISABLE_WP_CRON` constant is set; errors if true
* because WP-Cron is disabled.
* * Checks to see if the `ALTERNATE_WP_CRON` constant is set; warns if true.
* * Attempts to spawn WP-Cron over HTTP; warns if non 200 response code is
* returned.
*
* ## EXAMPLES
*
* # Cron test runs successfully.
* $ wp cron test
* Success: WP-Cron spawning is working as expected.
*/
public function test()
{
if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON) {
WP_CLI::error('The DISABLE_WP_CRON constant is set to true. WP-Cron spawning is disabled.');
}
if (defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON) {
WP_CLI::warning('The ALTERNATE_WP_CRON constant is set to true. WP-Cron spawning is not asynchronous.');
}
$spawn = self::get_cron_spawn();
if (is_wp_error($spawn)) {
WP_CLI::error(sprintf('WP-Cron spawn failed with error: %s', $spawn->get_error_message()));
}
$code = wp_remote_retrieve_response_code($spawn);
$message = wp_remote_retrieve_response_message($spawn);
if (200 === $code) {
WP_CLI::success('WP-Cron spawning is working as expected.');
} else {
WP_CLI::warning(sprintf('WP-Cron spawn succeeded but returned HTTP status code: %1$s %2$s', $code, $message));
}
}
示例14: make_request
/**
* Makes an HTTP request using WordPress' WP_Http class and related functions.
*
* @param RESTian_Request $request
* @param RESTian_Response $response
* @return RESTian_Response
*/
function make_request($request, $response)
{
switch ($request->http_method) {
case 'GET':
$url = $request->get_url();
$args = $this->get_args($request);
$result = wp_remote_get($url, $args);
break;
case 'POST':
if ($content_type = $request->get_content_type()) {
$request->add_header('Content-type', $content_type);
}
$url = $request->get_url();
$args = $this->get_args($request);
$result = wp_remote_post($url, $args);
break;
case 'PUT':
$result = new WP_Error(-1, 'HTTP PUT not yet supported.');
break;
case 'DELETE':
$result = new WP_Error(-2, 'HTTP DELETE not yet supported.');
break;
}
if (method_exists($request->client, 'filter_result')) {
$result = $request->client->filter_result($result, $response);
}
if (is_wp_error($result)) {
/**
* These errors likely won't be 100% compatible with the errors from CURL when standalone
*/
$error_num = $result->get_error_code();
$response->set_http_error($error_num, $result->get_error_message($error_num));
} else {
$response->message = wp_remote_retrieve_response_message($result);
}
$response->status_code = wp_remote_retrieve_response_code($result);
$response->body = wp_remote_retrieve_body($result);
$response->body = $request->client->apply_filters('result_body', $response->body, $response);
$response->result = $result;
return $response;
}
示例15: process
function process()
{
global $wp_version, $wpdb, $wpmudev_un;
$mysql_vars = array('key_buffer_size' => true, 'max_allowed_packet' => false, 'max_connections' => false, 'query_cache_limit' => true, 'query_cache_size' => true, 'query_cache_type' => 'ON');
$variables = $wpdb->get_results("\n\t\t\tSHOW VARIABLES\n\t\t\tWHERE Variable_name IN ( '" . implode("', '", array_keys($mysql_vars)) . "' )\n\t\t");
if (is_resource($wpdb->dbh)) {
$version = mysql_get_server_info($wpdb->dbh);
$driver = 'mysql';
} else {
if (is_object($wpdb->dbh) and method_exists($wpdb->dbh, 'db_version')) {
$version = $wpdb->dbh->db_version();
$driver = get_class($wpdb->dbh);
} else {
$version = $driver = '<span class="qm-warn">' . __('Unknown', 'wpmudev') . '</span>';
}
}
$this->data['db'] = array('version' => $version, 'driver' => $driver, 'vars' => $mysql_vars, 'variables' => $variables);
$this->data['php']['version'] = phpversion();
foreach ($this->php_vars as $setting) {
$this->data['php']['variables'][$setting] = @ini_get($setting);
}
$this->data['php']['extensions'] = get_loaded_extensions();
natcasesort($this->data['php']['extensions']);
$this->data['php']['error_reporting'] = error_reporting();
# @TODO put WP's other debugging constants in here, eg. SCRIPT_DEBUG
$this->data['wp'] = array('Version' => $wp_version, 'ABSPATH' => self::format_constant('ABSPATH'), 'WP_CONTENT_DIR' => self::format_constant('WP_CONTENT_DIR'), 'WP_PLUGINS_DIR' => self::format_constant('WP_PLUGINS_DIR'), 'SUNRISE' => self::format_constant('SUNRISE'), 'UPLOADBLOGSDIR' => self::format_constant('UPLOADBLOGSDIR'), 'UPLOADS' => self::format_constant('UPLOADS'), 'SUBDOMAIN_INSTALL' => self::format_constant('SUBDOMAIN_INSTALL'), 'DOMAIN_CURRENT_SITE' => self::format_constant('DOMAIN_CURRENT_SITE'), 'PATH_CURRENT_SITE' => self::format_constant('PATH_CURRENT_SITE'), 'SITE_ID_CURRENT_SITE' => self::format_constant('SITE_ID_CURRENT_SITE'), 'BLOGID_CURRENT_SITE' => self::format_constant('BLOGID_CURRENT_SITE'), 'COOKIE_DOMAIN' => self::format_constant('COOKIE_DOMAIN'), 'COOKIEPATH' => self::format_constant('COOKIEPATH'), 'SITECOOKIEPATH' => self::format_constant('SITECOOKIEPATH'), 'DISABLE_WP_CRON' => self::format_constant('DISABLE_WP_CRON'), 'ALTERNATE_WP_CRON' => self::format_constant('ALTERNATE_WP_CRON'), 'DISALLOW_FILE_MODS' => self::format_constant('DISALLOW_FILE_MODS'), 'WP_HTTP_BLOCK_EXTERNAL' => self::format_constant('WP_HTTP_BLOCK_EXTERNAL'), 'WP_ACCESSIBLE_HOSTS' => self::format_constant('WP_ACCESSIBLE_HOSTS'));
$server = explode(' ', $_SERVER['SERVER_SOFTWARE']);
$server = explode('/', reset($server));
if (isset($server[1])) {
$server_version = $server[1];
} else {
$server_version = 'Unknown';
}
$this->data['server'] = array('name' => $server[0], 'version' => $server_version, 'address' => $_SERVER['SERVER_ADDR'], 'host' => @php_uname('n'));
$remote_get = wp_remote_get($wpmudev_un->server_url);
$remote_post = wp_remote_post($wpmudev_un->server_url);
$remote_paypal = wp_remote_post("https://api-3t.paypal.com/nvp", array('body' => '"METHOD=SetExpressCheckout&VERSION=63.0&USER=xxxxx&PWD=xxxxx&SIGNATURE=xxxxx'));
$this->data['remote']['WPMU DEV: GET'] = is_wp_error($remote_get) ? $remote_get->get_error_message() : wp_remote_retrieve_response_message($remote_get);
$this->data['remote']['WPMU DEV: POST'] = is_wp_error($remote_post) ? $remote_post->get_error_message() : wp_remote_retrieve_response_message($remote_post);
$this->data['remote']['PayPal API: POST'] = is_wp_error($remote_paypal) ? $remote_paypal->get_error_message() : wp_remote_retrieve_response_message($remote_paypal);
}