Hey! Keep up to date with the project through its beta and public launch by following @getsparks.

 
1
1
0
685 Installs

Basic Information: twitterfetcher

Simple library for displaying Twitter feed data supporting a variety of customization/integration options

Contributor : joeauty
Email : Log in to view
Author Website : http://www.netmusician.org
Spark Website : https://github.com/joeauty/TwitterFetcher-CodeIgniter-Spark
Repository Type : git
Number of Installs : 685

Get the Latest

  • 1.1.0 Pushed April 11th, 2012
    php tools/spark install -v1.1.0 twitterfetcher Or download this version manually: Get twitterfetcher-1.1.0.zip

How-To

TwitterFetcher

TwitterFetcher fetches Twitter data via the provided Twitter username, and supports the following options:

  • specify how many tweets to fetch
  • specify whether tweets should be returned as JSON or XML data
  • an optional cache file which allows local retrieval of tweets to reduce the number of outbound Twitter connections being made by your site
  • a "cacheduration" parameter which dictates how often this cache file should be regenerated
  • specify whether Twitter links embedded in tweets should be automatically formatted into clickable links
  • support for multiple Twitter feeds
  • a human friendly "created at" string that is attached to the object returned in the format of "minutes/days/hours ago", seen frequently on various sites that display recent tweets
  • set a cutoff number of days to fetch tweets for

Dependencies

This library depends on the following CodeIgniter Sparks:

  • http://getsparks.org/packages/restclient/versions/HEAD/show
  • http://getsparks.org/packages/curl/versions/HEAD/show

Variables

  • twitterID (no default, required): the twitter username/ID you wish to fetch tweets for
  • count (int, default = 1): number of tweets to fetch, setting this to 0 will fetch all tweets for the specified user
  • format (json/xml, default = json): specify the format of the data structure returned
  • usecache (true/false, default = true): whether or not to use a local cache file, which needs to be located at application/cache/twitterstatus.[format], where "format" is either "xml" or "json", and writable by the web server. For first time use this file can be blank, it will be populated after your cacheduration time has elapsed
  • cachefile (provide custom cache file name to replace the default twitterstatus.[format] with [cachefile].[format])
  • cacheduration (int, default = 5, only relevant if "usecache" is set): regenerate the local cache file if it is older than this value, in minutes
  • createlinks (true/false, default = true): whether or not to convert Twitter links embedded in tweets into clickable links
  • numdays (int, no default): only fetch tweets newer than this number of days

Usage Example

<?php
$tweets = $this->twitterfetcher->getTweets(array(
    'twitterID' => 'netmusicianorg',
    'usecache' => false,
    'count' => 0,
    'numdays' => 30
));
print_r($tweets);
?>

elapsedtime String

In the above example, the variables "tweets" will be an array consisting of multiple tweets for when count is some value other than 1, or a single tweet object if it is set to 1. A non-standard property will be attached to the object called "elapsedtime" which is a human friendly elapsed time string in the format of "minutes/days/hours ago"

Changelog

1.1.0

  • don't generate an error if twitter feed does not exist
  • custom cachefile variable support
  • error check if cache file is writable, not if cache exists
  • automatically generate cache the first time if it doesn't exist
  • bump CodeIgniter compatibility to 2.1

1.0.4

  • fixed a bug that prevented page renders when Twitter REST request returns an empty array

1.0.3

  • use the URL scheme documented in the Twitter API documentation, thanks to subdesign for pointing out this flaw!

Older Versions

  • 1.0.4 Pushed August 17th, 2011
    php tools/spark install -v1.0.4 twitterfetcher Or download this version manually: Get twitterfetcher-1.0.4.zip
  • 1.0.4 Pushed August 17th, 2011
    php tools/spark install -v1.0.4 twitterfetcher Or download this version manually: Get twitterfetcher-1.0.4.zip
  • 1.0.3 Pushed July 5th, 2011
    php tools/spark install -v1.0.3 twitterfetcher Or download this version manually: Get twitterfetcher-1.0.3.zip
  • 1.0.2 Pushed May 28th, 2011
    php tools/spark install -v1.0.2 twitterfetcher Or download this version manually: Get twitterfetcher-1.0.2.zip
  • 1.0.1 Pushed May 28th, 2011
    php tools/spark install -v1.0.1 twitterfetcher Or download this version manually: Get twitterfetcher-1.0.1.zip

Comments

blog comments powered by Disqus