WordPress Google Reader Widget

Number 3 in Widget-A-Day is a Google Reader widget.

This widget will display your latest shared stories. You can change the amount of stories to display and how to display them.

Download googlereader.zip

Default display:
googreader1cropped.png

Admin panel:
googreader2cropped.png

Download googlereader.zip

SVN Checkout
svn co http://svn.wp-plugins.org/google-reader-widget/trunk

Requirements

Installation

  1. Download googlereader.zip
  2. Extract and upload googlereader.php to the plugins/ directory
  3. Enable Google Reader in the Plugin admin panel
  4. In widget admin panel, place Google Reader in the sidebar, and edit it to enter your user id

Features

  • Displays your latest shared items from Google Reader
  • Completely customizable display
  • Caching for large traffic sites


User ID

In order to get your shares, you need to know your user id according to Google Reader. This can be found by going to the 'Shared Items' link, and copying the 20 digit number at the end of your shared items link.

So something like:
http://www.google.com/reader/shared/02774557510273097991
Where 02774557510273097991 would be my user id.

Formatting

There are 3 parts needed to format the output.

The first part, called items start in the admin panel, is the first part of the widget after the title. For the default formatting, this is just <ul>.

The second part, called items end, is the ending of the widget. By default, this is:
</ul>
<a href="%googlereader%" style="float:right;">Shared Items</a>

The third part is what is called for each item. By default, this is:
<li style="list-style-type: none;"><a href="%link%">%title%</a></li>

The premise of calling each value is this:

  1. start
  2. item
  3. item
  4. item
  5. end

The formatting for items is:

  • %link% – Link to the item
  • %title% – Title of the item
  • %site% – The title of the site the item is from
  • %sitelink% – The link to the site the item is from
  • %number% – The number of the current item
  • %comment% – The comment (note) made when sharing an item

The formatting for start and end is:

  • %googlereader% – Link to your Google Reader shared page
  • %count% – Number of items shown

Download googlereader.zip

162 Comments

  1. [...] Google Reader Widget Ein weiteres, wie ich finde, großartiges Plugin, welches es per Text-Widget ermöglicht, in der [...]

  2. -20 says:

    At the end of every link '/fromfeed' is added so I alway direct people to a 404.

    My bad maybe, but I'm missing what I did wrong

  3. James says:

    It's probably because of an error in the script. On line 47, it should be $after_widget (Thanks Ryan). I had fixed it before, but it slipped back in. You can either change it or download it again and you shouldn't have that problem. If you still do, it's probably something else and I can look into it.

  4. -20 says:

    Hey James,

    Thanks for that quick response, the solution however didn't work. The '/formfeed' is still around.

    If you could check the thing out in the wild on my site, don't rush, I'm patient.

    Thanks again,

    Ger

  5. -20 says:

    Hey James,

    No need to look further, problem solved. Shared one item from particular site, think this site adds '/fromfeed' themselves.

    Won't be shared any longer.

  6. [...] Google Reader : This excellent widget displays your recent shared items in Google reader. Google reader is my [...]

  7. [...] Google Reader Widget – Denna ser till att jag snyggt kan lista alla inlägg som jag delat med mig av i min Google Reader. När jag läser nÃ¥got jag tycker att andra ska läsa, delar jag ut det och det dyker automagiskt upp i "sidebar" (högerspalten) pÃ¥ http://www.asiktstorped.se/inspiration [...]

  8. thesimplicity says:

    I can't get this to work for the life of me. The widget displays fine but no stories show up. I've double checked all the user variables, I'm running wordpress 2.5 and PHP 5, so I'm not sure what could be wrong.

  9. acedanger says:

    I'm having the same problem thesimplicity is describing

  10. jayncoke says:

    same thing happening for me as thesimplicity and acedanger. would love to see this working…

  11. James says:

    Can any of you give me a screenshot or just the values in your widget admin panel?

    If you don't want to put it here, you can send it to j{at}meswilson.com

  12. James says:

    Uggh, that's disappointing. Just tried a fresh 2.5.1 install. No problem.

    Maybe a list of your plugins installed or phpinfo() or something. Maybe file_get_contents is returning "" for some reason.

    You could try something like:

    <?php
    header("Content-type: text/xml");
    echo file_get_contents('http://www.google.com/reader/public/atom/user/01748055517437296386/state/com.google/broadcast');
    ?>

    And see if it outputs this.

    If it doesn't or just nothing, then it's file_get_contents.

    Same config:
    http://nothingoutoftheordinary.com/gr-sized-1.png
    Results:
    http://nothingoutoftheordinary.com/gr-sized-2.png

  13. acedanger says:

    code on my site does not output the same thing as the your site: http://www.dfktv.com/file_get_contents.php. from the output, file_get_contents is disabled. I'm using dreamhost.

    here is my phpinfo page http://www.dfktv.com/phpinfo.php

  14. acedanger says:

    looks like file_get_contents is disabled (using dreamhost) http://www.dfktv.com/file_get_contents.php
    phpinfo page – http://www.dfktv.com/phpinfo.php

  15. acedanger says:

    file_get_contents is disabled apparently: http://www.dfktv.com/file_get_contents.php
    here is my phpinfo page http://www.dfktv.com/phpinfo.php

  16. James says:

    Then that's the problem. Earlier in the comments there is a way to make it work with curl instead of file_get_contents.

    I was planning on making it an option to use whichever, but haven't yet gotten around to do it. Depending on what I'm doing tomorrow, I might do it then.

  17. acedanger says:

    sorry for all of the duplicate posts, I was having some website issues last night with posting…

  18. thesimplicity says:

    ack, I'm on Dreamhost as well. I had no idea they disabled file_get_contents by default. I'd LOVE a version of this that uses cURL.

  19. [...] Nothing to see here… » WordPress Google Reader Widget [...]

  20. Velanche says:

    Hi There:
    This widget looks promising. The problem is that I'm working with a 3-column theme that's supposed to be widgetized. Whenever the widget is turned on and place, it totally replaces the sidebar with the widget and, thus, effectively rids of the other items on my sidebar.

    If I understand the theme that I'm working on, the two sidebars (right and left) start off "after the divs) with a class for each sidebar, yet the class names aren't in the CSS itself.

    I'd love to use the widget, or at least be pointed to a similar plugin. Oh, I am using WP 2.5 on a production machine.

    Thanks; hope to hear from you,
    Velanche

  21. Fred says:

    Weirdly, it seems that if the title for the box is too long, access to the admin panel is lost.

  22. dimon_prodigy says:

    Is there a version for WP2.5.1?

  23. Ben Wagaman says:

    If you want to use CURL on DH, replace:
    $stories = file_get_contents($uri);

    with
    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL, $uri);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
    $stories = curl_exec($ch);
    curl_close($ch);

  24. acedanger says:

    Thanks Ben, that worked as expected. Of course, as I was editing the code, I happened to look in the README file and saw those exact instructions.

  25. Brian says:

    I've just started using this widget a few days ago on my brand new WordPress blog. I'm in the process of moving my BlogSpot blog over, and had to find a replacement for the Google Shared Items. So far… it's ok, but I'm having problems. It seems that when I share items, then go look at my blog to ensure they're showing up – they're not. I have to edit the widget, make a change (or I just discovered not even change anything), then click Change, and Save Changes, then when I refresh my blog the newly shared items appear. This is on WP 2.5.1. Anybody else seeing this, or have a clue how to fix it?

  26. James says:

    @Brian, That's probably because the results are cached (default 60 minutes or 3600 seconds). You can turn off caching by setting cache time to 0 or -1, which will request the shared items feed every page load. Or you can just lower it to something like 15 minutes or 900 seconds to have it update more frequently.

  27. dimon_prodigy says:

    Anybody know – how to display ALL latest stories from Google Reader, not only SHARED?

  28. Schulte says:

    James, are you planning on adding the ability to designate a tag so users can show certain shared items?

  29. James says:

    @Schulte, updated. Only one tag is supported though. If you can have a multiple tags on the RSS feed, let me know.

  30. Leonaut.com says:

    WordPress Google Reader Widget…

    This widget will display your latest shared stories. You can change the amount of stories to display and how to display them….

  31. Timmy says:

    Any Idea? It was working on wp 2.5.1 until I upgraded to 1.6 yesterday.

  32. Timmy says:

    I managed to revert this to version 1.5 and it works on WP 2.5.1

  33. James says:

    @Timmy, I did it wrong. I thought since I only changed a few lines, I couldn't screw it up, so I didn't test it.

    I fixed it. I tested it on a fresh install of 2.5.1, and it seemed to work. So you can upgrade to 1.7, and it should be good.

    If you aren't going to use the tag functionality though, you can keep using 1.5. But I did find that since it had extra whitespace after the ?>, it caused an error after saving the widget configuration.

  34. chris says:

    Is there a way to have a clicked link open in another tab/window for this widget? I want to share my shared google items, but don't want people to leave my page. Thanks.

  35. James says:

    @chris, add target="_blank" after the href="..." in items end and item.

    So, something like <a href="%link%"> would become <a href="%link%" target="_blank">

  36. Schulte says:

    James, that did it. Thanks. For your consideration — how about adding support for multiple Google Reader Widgets (see Flexi Pages widget for an example)?

  37. Petyo says:

    Patch to show user comments:

    Removed. See next comment

  38. Petyo says:

    Somehow the previous comment did not work as I expected, so here is the patch with user comments:

    http://underlog.org/googlereader.patch

  39. James says:

    Yeah, WordPress destroyed that comment formatting.

    Nice work. Added it to the main version.

  40. Chris says:

    James thank you so much! It worked – guess I need to brush up on my HTML

    Chris
    http://www.politicalpitstop.com

  41. [...] administration tool, and I was able to add links to my Google Reader shared items by dropping a plugin in the right spot. If you're a blogger, or are thinking of starting, and run your own server, [...]

  42. Andrew says:

    This is a great plugin! I know it's been a while since you've been making a widget a day, but widgets that showed delicious links and facebook posted items would be stellar. Keep up the good work.

  43. cd says:

    Is there a way to insert manual code into a theme instead of using the widget?

  44. Hi,
    I am trying to make a dedicated page for my Google Reader shared items.

    Is it possible to insert this into a page, rather than into the sidebar?

    Thanks,
    Josh

  45. Hi. Thanks for this plugin! It's great.

    My blog has multiple authors, so what I'd like to do is have your plugin running multiple times on the sidebar — once for my list, once for a co-blogger's list, and again for a different co-blogger's list (etc). But wordpress only gives me the option of putting it on the sidebar once. Is there any way around this, that you know of?

    Thanks!

Leave a Reply