I was recently working on a website in Open source and blog of that site was being managed on Blogger.com, in general case when blog is self hosted on same domain or is in WordPress is become quite easy to show the post on the website. Here also the same requirement was faced where I had to show the blog post on website but from blogger.com
Initially is sounded something quite complex due to my limited exposure with blogger but once I checked the post structure it become quite easy to achieve this. I did this using MagpieRSS, a free to use open source project for converting various types of RSS feed. I support Blogger too. Step by step process to achieve this is as below:
Step 1: Download Magpie RSS
Step 2: Extract downloaded files in a directory named magpierss in ROOT of your project.
Step 3: Open PHP page where we need to display list of post from blogger and paste below code, I assume you :
{code}
{/code}
Now we have to display post data fetched from blogger:
a. If you want to display POST TITLE along with DESCRIPTION from blogger on your website, use below code:
{code}
//display latest blog content:
$item = $rss->items[0];
$content = $item[‘atom_content’];
echo “
Latest Blog Entry:
$content
\n”;
?>
{/code}
b. If you want to display POST TITLE ONLY from blogger on your website, use below code:
{code}
//display links recent blog entries:
echo "
- Latest blog additions:\n”;
- $title $created
foreach ($rss->items as $item) {
$href = $item[‘link’];
$title = $item[‘title’];
$created = $item[‘created’];
echo “
\n”;
}
echo “
“;
?>
{/code}
c. b. If you want to display ‘N’ number of POST TITLE from blogger on your website, a small change in above code is required and it will be as below:
{code}
echo "
Latest blog additions
- “;
- $title
define(‘MAGPIE_DIR’, ‘magpierss/’);
require_once(MAGPIE_DIR.’rss_fetch.inc’);
$num_items = 7; // Number of post we wish to display
$rss = fetch_rss( ‘http://yourblogname.blogspot.com/atom.xml’ );
$items = array_slice($rss->items, 0, $num_items);
foreach ($items as $item) {
$href = $item[‘link’];
$title = $item[‘title’];
echo “
\n”;
}
echo “
“;
?>
{/code}