wp_remote_fopen

函数


wp_remote_fopen ( $uri )
参数
  • (string)
    $uri
    URI/URL of web page to retrieve.
    Required:
返回值
  • (string|false) HTTP content. False on failure.
相关
  • wp_safe_remote_get()
定义位置
  • wp-includes/functions.php
    , line 1299
引入
1.5.1
弃用

对URI的HTTP请求,以检索内容。

function wp_remote_fopen( $uri ) {
	$parsed_url = parse_url( $uri );

	if ( ! $parsed_url || ! is_array( $parsed_url ) ) {
		return false;
	}

	$options            = array();
	$options['timeout'] = 10;

	$response = wp_safe_remote_get( $uri, $options );

	if ( is_wp_error( $response ) ) {
		return false;
	}

	return wp_remote_retrieve_body( $response );
}