返回介绍

wp_remote_retrieve_body()

发布于 2017-09-11 12:44:47 字数 3489 浏览 1207 评论 0 收藏 0

wp_remote_retrieve_body( array $response )

Retrieve only the body from the raw response.


description


参数

$response

(array) (Required) HTTP response.


返回值

(string) The body of the response. Empty string if no body or incorrect parameter given.


源代码

File: wp-includes/http.php

function wp_remote_retrieve_body( $response ) {
	if ( is_wp_error($response) || ! isset($response['body']) )
		return '';

	return $response['body'];
}

更新日志

Versiondescription
2.7.0Introduced.

相关函数

Uses

  • wp-includes/load.php: is_wp_error()

Used By

  • wp-admin/includes/class-wp-community-events.php: WP_Community_Events::get_events()
  • wp-admin/includes/class-wp-press-this.php: WP_Press_This::fetch_源代码_html()
  • wp-admin/includes/translation-install.php: translations_api()
  • wp-admin/includes/network.php: network_step2()
  • wp-admin/includes/theme.php: themes_api()
  • wp-admin/includes/update.php: get_core_checksums()
  • wp-admin/includes/dashboard.php: wp_check_browser_version()
  • wp-admin/includes/plugin-install.php: plugins_api()
  • wp-admin/includes/import.php: wp_get_popular_importers()
  • wp-admin/includes/credits.php: wp_credits()
  • wp-includes/functions.php: wp_remote_fopen()
  • wp-includes/deprecated.php: wp_get_http()
  • wp-includes/class-wp-simplepie-file.php: WP_SimplePie_File::__construct()
  • wp-includes/update.php: wp_version_check()
  • wp-includes/update.php: wp_update_plugins()
  • wp-includes/update.php: wp_update_themes()
  • wp-includes/class-oembed.php: WP_oEmbed::discover()
  • wp-includes/class-oembed.php: WP_oEmbed::_fetch_with_format()
  • wp-includes/class-wp-http-ixr-client.php: WP_HTTP_IXR_Client::query()
  • wp-includes/rss.php: _fetch_remote_file()
  • wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::pingback_ping()
  • wp-includes/comment.php: discover_pingback_server_uri()
  • Show 17 more used by Hide more used by

User Contributed Notes

  1. Skip to note content You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note Contributed by Codex

    Example

    Retrieving data from a JSON API:

    
    $url      = 'http://example.org/api';
    $response = wp_remote_get( esc_url_raw( $url ) );
    
    /* Will result in $api_response being an array of data,
    parsed from the JSON response of the API listed above */
    $api_response = json_decode( wp_remote_retrieve_body( $response ), true );
    

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文