Welcome Guest, Not a member yet? Register   Sign In
Caching and combing feeds from Facebook, Twitter and Instagram
#1

[eluser]Unknown[/eluser]
I'm a non-profit website with a 'stream' page which brings in photos from instagram (hashtag search), updates and photos from Facebook (via festival's albums) twitter posts (by user and hashtag).

I've used the JS widgets for Facebook and Twitter before but would like to use Codeigniter to pull the feeds and cache them somehow for better performance and more control over the display on my site.

I'm leaning toward a MySQL table with a record for each feed, that would basically just store the feed URL, data (json format), last updated time and an identifier of some sort.

Then I could write a class with the following type of methods:

get_feed($id='facebook_updates', $expiry_time=3600);

Does this seem like a reasonable way to go? or is there a better solution already existing?

#2

[eluser]boltsabre[/eluser]
I've never done it myself, but by the sounds of it you're make a request to FB (I'll just stick with that for now), getting the last XYZ number of posts.

I'd just write them direct into an array (the feed url, data, etc) - basically you make your request, loop over the results and write them into your array - and cache that array for 3600. Saves mucking around with another layer of complexity, no need for DB hits, etc.
Alternatively, as you're looping over your results you could write it direct into a string with html markup if you don't want to do it in your view and cache the string. However, then you are stuck with that "html" markup where ever you want to display your feeds, very hard to alter. Your choice, whatever works best for you!

Does that help?




Theme © iAndrew 2016 - Forum software by © MyBB