Friendfeed Plug-in For Sweetcron
Wednesday, October 7th, 2009
The following is a guide to setting up a plug-in to import your posts from FriendFeed into lifestreaming service SweetCron. It’s a good idea to take a look at the official guide for Sweetcron Plug-ins before following this guide.
Your not going to want to import your entire FriendFeed stream into Sweetcron because it will include many duplicate posts from twitter, youtube, flickr, etc. For this reason we’ll use a RSS feed from FriendFeed Search instead of importing your full FriendFeed stream.
Note: I have not tested this code with any other account yet, if you have any problems please report them in the comments. – Mitchell
Once you’ve added the code from this guide, simply add the following feed to the feeds section in the Sweetcron Admin panel replacing [username] with your FriendFeed username:
http://friendfeed.com/search?q=from%3A[username]+service%3Afriendfeed&format=atom
Here’s the code for friendfeed_com.php which goes in the plug-ins folder (replace [FIRSTNAME] with what friendfeed uses as your first name):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Friendfeed_com { function pre_db($item, $original){ //fix content $content = explode('Like', $item->item_content, 2); //remove everything before "like" //remove html tags from beginning $content = substr($content[1], 12); //get rid of everything after "[FIRSTNAME]" $content = explode('[FIRSTNAME]', $content, 2); //trim off that trailing dash (-) $content = substr($content[0], 0, -2); $item->item_content = $content; //fix title $item->item_title = substr($item->item_title, 18); return $item; } function pre_display($item){ //grabs the small thumbnail as the image $item->item_data['image'] = $item->item_data['enclosures'][0]->thumbnails[0]; /* Use this code if you want the full picture and not the thumbnail! * $big_pic = $item->item_data['enclosures'][0]->link; //check if is image $format = substr($big_pic, -4); if ($format == '.jpg' || $format == '.gif' || $format == '.png') { $item->item_data['image'] = $big_pic; } * */ //Fix for old imports with (via FriendFeed) in them if(substr($item->item_title,-17,17) == " (via FriendFeed)"){ $item->item_title = substr($item->item_title,0,(strlen($item->item_title)-17)); } //remove small icons and avatars as image if (substr($item->item_data['image'], 0, 42) == 'http://friendfeed.com/static/images/icons/'){ $item->item_data['image'] = ''; } if (substr($item->item_data['image'], 0, 26) == 'http://i.friendfeed.com/p-') { $item->item_data['image'] = ''; } return $item; } } |
In _activity_feed.php before the line…
1 2 | <?php else: //generic container with instructions ?> <div class="inner_container instructions"> |
Add the following code:
1 2 3 4 | <!--Container for friendfeed-->
<?php elseif ($item->get_feed_domain() == 'friendfeed.com'): ?>
<p class="activity_image_text"><a href="<?php echo $item->get_permalink()?>/<?php echo $item->get_name()?>"><?php echo $item->get_title()?></a><span class="activity_image_content"></span></p>
<a class="activity_image" href="<?php echo $item->get_permalink()?>/<?php echo $item->get_name()?>" style="background: url(<?php echo $item->get_image()?>) center center no-repeat"></a> |
If you are using the boxy theme, you can make your posts look like the picture above by editing main.css to include:
1 2 3 4 5 6 7 8 9 10 11 12 | a.activity_image { display: block; height: 250px; } p.activity_image_text { position: absolute; top: 0; padding: 3px 5px; background-color:rgba(0,0,0,0.85); } |
Should be good to go!