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_remote_getwp_remote_postwp_remote_headwp_remote_requestwp_safe_remote_get
引入
1.5.1
弃用
-

wp_remote_fopen: 这个函数用来打开一个远程文件以供阅读。它接受一个参数:远程文件的URL。

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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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 );
}
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 ); }
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 );
}

常见问题

FAQs
查看更多 >