How To Parse RSS Feeds with MagpieRSS

Using MagpieRSS is one of the simplest ways to parse RSS feeds. One use of this is when you want to display updated contents from a site to your website. In this post, we are going to get the Top Stories news of "The Worldwide Leader in News", the CNN. We will just use one of their RSS feed links: http://rss.cnn.com/rss/cnn_topstories.rss. CNN provides all of their RSS feeds links, you can find them in this link http://edition.cnn.com/services/rss/. We just have to agree to their terms of use listed on that page.

How To Parse RSS Feeds with MagpieRSS
Want some feeds?

Step 1: Download MagpieRSS on sourceforge (I got magpierss-0.72) and place it in your web directory. I got the following files:



Step 2: Coding.

index.php

<html>
<head>
<title>Parsing RSS feeds with MagPie RSS</title>
</head>
<body>
<?php

require_once('rss_fetch.inc');

//Specify the URL of RSS feeds
$rss = fetch_rss("http://rss.cnn.com/rss/cnn_topstories.rss");

foreach ( $rss->items as $item ) { //loop through the $rss array which contains the feeds
    echo "<div style='margin: 5px 0 5px 0;'>";
    echo "<div style='font-weight: bold;'>{$item['title']}</div>";
    echo "<div style=''>{$item['description']}</div>";
    echo "</div>";
}
?>
</body>
</html>

If we will take a look at http://rss.cnn.com/rss/cnn_topstories.rss, we have:


On our index.php code, title and description inside $item variable are from the XML tags of RSS feed. If you will view-source http://rss.cnn.com/rss/cnn_topstories.rss, you will see:

Please Click to enlarge

This is an item in our RSS feed. The values between title and description tags are echoed in our program. You can also echo the link, pubDate, etc. since those tags are there too.

Step 3: Run the program. The ouput of our code would be something like:



You may want to:


That's it! Now you can embed some contents from an RSS feeds to your website!

Home Facebook

Social Network Integration

Social Network Integration
Familiar huh?

Facebook? Twitter? You are probably very familiar or even addicted to them. To date, it is almost impossible for people who use the internet to miss an account with them. They are free, easy to use and lets you connect with your friends or people no matter where on earth they are. Wikipedia defines social networking service as “…an online service, platform, or site that focuses on building and reflecting of social networks or social relations among people, e.g., who share interests and/or activities”. There are so many social networking service sites out there and two of the most popular includes facebook and twitter.

Most internet users are visiting their facebook account everyday. It just shows that the world has gone social. When you log in to your facebook account, you can check and see how many of your friends are online. Large number of people are getting online every day and make it as essential part of their life. They connect with each other, playing games, sharing activities, interests, etc. with their network of friends. They join conversations and discover contents that can be of meaningful value for them. The social network is active and authentic since it is made up of real people - and these people can be the consumers for your business.

With that said, we can conclude that it is beneficial for businesses to integrate social networks, such as facebook and twitter, to their web presence or websites. Once a user like, recommend or tweet your website, it will be shared to their network of friends and this personal recommendation is a powerful kind of endorsement. Your website will have more opportunity to be visited that offers your products and/or services to be known to customers.

Maybe you are aware of how many people can find your facebook page or tweets? According to Wikipedia, facebook now has over 600 million active users all over the world while twitter has 200 million (as of January 2011). It’s now a privilege for your business to join these social networking sites to keep in touch of your customers and get the edge by integrating it to your website.


I have the following tutorials related to Social Network Integration: