简体   繁体   English

wp_remote_get失败,并显示“从对等方接收数据时失败”

[英]wp_remote_get fails with “Failure when receiving data from the peer”

I'm trying to get file contents of a file with this: 我正在尝试通过以下方式获取文件的文件内容:

$google_fonts = (array)wp_remote_get( THEME_ADMIN_URI.'/google_fonts.txt' );

On var_dump($google_fonts); var_dump($google_fonts); it prints this: 它打印此:

array(2) {
    ["WP_Errorerrors"]=> array(1) { 
        ["http_request_failed"]=> array(1) { 
            [0]=> string(41) "Failure when receiving data from the peer" 
        }
    }
    ["WP_Errorerror_data"]=> array(0) { }
}

This is the first time I see this. 这是我第一次看到这个。 I'm on a support task on a foreign server and WP Installation, so I have limited access, especially to php and server settings. 我正在外部服务器和WP Installation上进行支持任务,因此访问权限有限,尤其是对php和服务器设置的访问权限。 Path is good, and on my server and localhost, it works fine. 路径是好的,并且在我的服务器和本地主机上,它工作正常。 File can be accessed directly in browser. 可以在浏览器中直接访问文件。

If I try to use file_get_contents() based on the local directory not the domain, it works. 如果我尝试基于本地目录而不是域使用file_get_contents() ,它将起作用。

Any ideas what's causing this? 任何想法是什么原因造成的?

我见过当请求的域使用CloudFlare时wp_remote_get()失败-有关SSL如何混淆CloudFlare的wp_remote_get()以及在正确配置SSL证书(站点和CloudFlare内部)时请求出错的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM