有关wp_remote_get()函数

在wordpress里写了个检测链接的功能,用wp_remote_get()去检测一个链接。 $response = wp_remote_get($url,  array(   ‘timeout’ => 8,   ‘user-agent’ => ‘Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:20.0) Gecko/20100101 Firefox/20.0’ )); 但奇怪的是,$response有时候是空的(就是没有访问到目标网址)报错为:cURL Error 28: Connection Timed Out。 有时候又是正常的。不正常的时候刷新整篇文章就又正常了。 我检查了很多方面的问题: 1.目标URL肯定是没问题的。 2.我的服务器与目标url之间的连通是正常的。 3.其他代码并没有bug 4.curl功能正常。 请问有大佬知道怎么解决吗?

请登录后发表评论

    没有回复内容