menu
William and Mary
search

Social Media RSS

An add-on to Mobile Web OSP

This add-on can be used to replace the default RSS services class in Mobile Web OSP. The add-on modifies the default RSS parser to use SimplePie and more comprehensively handles social media RSS feeds (Twitter, Facebook, Flickr and YouTube) by parsing the feed entries to make the information provided easier to display, with formatting removed so it can be styled to fit your site.

Download the code

Installation

  1. Unzip social-media-rss.zip and copy rss_services_simplepie_and_social_media.php into the /lib folder of your Mobile Web OSP installation
  2. Rename the existing rss_services.php file to rss_services_old.php
  3. Rename rss_services_simplepie_and_social_media.php to rss_services.php
  4. Download the SimplePie library and copy the library include file (simplepie-lib.inc) into the desired directory
  5. Open rss_services.php and update the SimplePie include path to point to the SimplePie library file from step 4
  6. Set the default values for cache directory location (RSS::default_cache_dir) and duration (RSS::default_cache_duration). Note: Be sure the default_cache_dir is a server-writeable directory.

Once you have specified an RSS feed you can see this plugin in action.

To best utilize the information provided in the social media feeds you will want to modify the display templates (located in the /templates/$prefix folder for each section) to eliminate duplicate information or to show information in a more intuitive or expected way (like a photo or thumbnail).

Documentation

In addition to the standard RSS fields (title, type, date, unixtime, author, link, and description or text) returned in the item array, this plugin adds social media-specific fields to provide greater detail from the content of the RSS item. Field names for each of the social media sources are described below; tips for how to locate the RSS feeds for each social media source are also included.

Facebook Item
  • title: The Facebook status text truncated (by Facebook) at 84 characters
  • type: "facebook"
  • date: Returns an associative array containing the date information of the post (utilizing PHP's getdate function)
  • unixtime: Returns a timestamp of the date of the post (utilizing PHP's strtotime function)
  • author: The source Page or Profile name
  • text: The full Facebook status text
  • link: Link to the full Facebook post, including comments
  • link_title: If a link was added to the post, the page title of that link
  • link_source: If a link was added to the post, the base URL of that link
  • link_caption: If a link was added to the post, the descriptive or introductory text of that link
  • link_thumbnail: If a link was added, the preview thumbnail of that link
  • link_url: If a link was added to the post, the full URL of that link

Facebook screenshot

RSS for a Facebook Page is of the format http://www.facebook.com/feeds/page.php?id=<page_id>&format=rss20. You can determine the Facebook Page RSS link by copying the "Get Updates via RSS" link at the bottom of the left menu.

Twitter Item
  • title: The "twitterfied" Twitter status (links, hashtags and usernames are linked the their appropriate Twitter pages or locations using a PHP regular expression)
  • type: "twitter"
  • date: Returns an associative array containing the date information of the tweet (utilizing PHP's getdate function)
  • unixtime: Returns a timestamp of the date of the tweet (utilizing PHP's strtotime function)
  • author: Who wrote the tweet
  • description: Same at title
  • link: The permalink to the tweet

Twitter screenshot

For Twitter, RSS for a user is http://twitter.com/statuses/user_timeline/<twitter_id>.rss You can determine the Twitter handle ID by visitinghttp://www.idfromuser.com/

Flickr Item 
  • title: Photo title
  • type: "flickr"
  • date: Returns an associative array containing the date the photo was uploaded (utilizing PHP's getdate function)
  • unixtime: Returns a timestamp of the date the photo was uploaded (utilizing PHP's strtotime function)
  • author: The user who uploaded the photo
  • description: The photo description 
  • link: Direct link to the photo
  • photo_thumbnail: The "square" (75px x 75px) photo thumbnail
  • photo_small: The "small" size of the photo
  • photo_fullsize: The full resolution version of the photo
  • photo_id: The Flickr ID of the photo

Flickr screenshot

At the bottom of each Flickr user or group's photostream there's a link to their latest RSS feed, something of the format http://api.flickr.com/services/feeds/photos_public.gne?id=<flickr_id>&lang=en-us&format=rss_200

YouTube Item
  • title: Video title
  • type: "youtube"
  • date: Returns an associative array containing the date the video was uploaded (utilizing PHP's getdate function)
  • unixtime: Returns a timestamp of the date the video was uploaded (utilizing PHP's strtotime function)
  • author: The user who uploaded the video
  • description: The video description 
  • link: Direct link to the YouTube video
  • video_length: Length of the video in minutes and seconds
  • video_thumbnail: Small screenshot preview of the video
  • video_views: Number of views of the video

YouTube screenshot

There is already a way to present YouTube videos in Mobile Web OSP, but for completeness it is included here. RSS for a YouTube user ishttp://gdata.youtube.com/feeds/base/users/<youtube_username>/uploads?orderby=published&max-results=<num_results>

General Item (News or Blog feeds)
  • title: Article title
  • type: "story"
  • date: Returns an associative array containing the date the story was published (utilizing PHP's getdate function)
  • unixtime: Returns a timestamp of the date the story was published (utilizing PHP's strtotime function)
  • author: The name of the author of the story
  • description: The story description 
  • text: The content of the story
  • link: Direct link to the story

License

The Social Media RSS add-on to Mobile Web OSP is released under the open-source MIT license.