wpseek.com
WordPress开发者和主题制作者的搜索引擎



wp_remote_fopen › WordPress Function

Since1.5.1
已弃用n/a
wp_remote_fopen ( $uri )
参数:
  • (string) $uri URI/URL of web page to retrieve.
    Required: Yes
查看:
返回:
  • (string|false) HTTP content. False on failure.
定义在:
文档:

HTTP request for URI to retrieve content.



源码

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 );
}