Archive - Jun 22, 2008
Adding Friend Feed comments to Drupal
Submitted by Aldon Hynes on Sun, 06/22/2008 - 08:50Last night, Bill Anderson added a Friend Feed comment on my Feed graph in Flickr.
Whoa! This is an engineering diagram that *is* a picture. What kind of systems are we building? The kind that Aldon has drawn here
What kind of systems are we building? Who is thinking about how all the moving pieces fit together? It is a very interesting line of thought to be following.
It led me to a different question. Are people adding comments to my friend feed that I, and others are missing? Have people commented on Orient Lodge blog posts over in Friend Feed?
At the same time I noticed that Friend Feed evangelist Steve Rubel posted a link: NEW FriendFeed Comment Widget (Blogger, Tumblr and FeedBurner).
It got me thinking. Can I add Friend Feed comments to Drupal? My first pass was to try and tweak some of the code in the article that Rubel linked to. That didn't work particularly well. So, I checked around on Drupal and found an example in this blog post
Doing a little tweaking, I came up with:
function friendfeedcomments(json) {
if (json.count > 0) {
var ffsection = "<div class='subheadlg' style='padding-top:15px;padding-bottom:10px;'>FriendFeed Comments:</div>"
for (var i = 0; i < json.count; ++i) {
var ffcomment = json.value.items[i];
ffsection = ffsection + "<dt class='comment-author friendfeed-comment-icon'><a href='" + ffcomment.link + "'>" + ffcomment.title + "</a>"
ffsection = ffsection + " says...</dt><dd class='comment-body'><p>" + ffcomment.description + "</p></dd>"
}
document.write(ffsection);
}
}
</script>
<script src='http://pipes.yahoo.com/pathawks/ffcomments?_callback=friendfeedcomments&_render=json&ffid=ahynes1&url=<?php print url($node_url,NULL,NULL,TRUE) ?>'>
</script>
which I added to my node.tpl.php file. Note: ahynes1 is my id on FriendFeed. If you lift this code, you should change ahynes1 to be whatever your FriendFeed id is, or you probably won't find any comments.
It looks like it is working. What would be really nice would be if I could add a link to the FriendFeed item even if there are no comments there, so that people could add comments on FriendFeed if they wanted to. That will wait for another round of tests.