Written on
十月 8, 2007 – 9:26 下午 | by paopao
从暑假开始使用 Google Reader ,最初只是用它最基本的功能——订阅。渐渐地,不再满足于简单阅读,开始使用星标、分享等功能。前几天突然想把我的 Google Reader 的分享内容加到我的侧边栏里,于是搜索了一圈,试用了几个插件,最后选定了 Google Reader Widget 这个插件。这个插件带有 widget ,添加方便,而且可以设置显示的方式。
现在本地测试了一下,没什么问题,顺便修改了一下默认的显示设置。但是传到本站却显示不了任何条目。在站点里找到一个error_log文件,里面有如下警告:
PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: URL file-access is disabled in the server configuration in /.../wp-content/plugins/googlereader.php on line 56
原来我的服务器的php.ini里的设置导致 file_get_contents 函数不能以 URL 作为参数,但是我又无法更改这个设置。好在 WordPress 给我们提供了一个 Snoopy 类来完成这件事,我在 Fanfou Daily 这个插件里也用到了这个类。修改 googlereader.php 的第56行从
$stories = file_get_contents($uri);
修改为
require_once ABSPATH.WPINC.'/class-snoopy.php';
$client = new Snoopy();
$headers = "";
if ( is_array($headers) ) $client->rawheaders = $headers;
@$client->fetch($uri);
if ( !($client->status >= 200 && $client->status < 300) ) return false;
$stories = $client->results;
这样就可以正常使用了,具体效果见本站侧边栏 ^_^
另外在这个插件页面的留言里有一个使用cURL的解决方案
Popularity: 39% [?]
Tags: google-reader, plugin, wordpress
Posted in 插件 | 7 Comments »