lineTwit is a PHP Twitter Reader based on the myTwit PHP Twitter Reader written by Ralph Slooten.

Whilst working on a project at work (Line Digital) I required a PHP twitter reader and myTwit fitted in very nicely and was very easy to get up and running, however, as with most things, I find I always need to make a few customisations and both Ralph Slooten and Line Digital have been very kind in allowing me to re-package my amendments for everyone to make use of.

Please feel free to leave any comments or suggestions.

The main customisations I have added are:-

  • Added a no-response file (to handle twitter timeouts)
  • Added ability to specify location to store cache files
  • Updated cache filename to allow multiple instances of lineTwit with different accounts
  • Separated the HTML for the twitter header and posts to allow the header to be excluded
  • Changed printError to send a notification email rather than display error message on screen

Download lineTwit

You can download the latest version of lineTwit via the link below:-

File Date Description
lineTwit_V1 2010-10-24 Initial Release

Usage

The lineTwit download comes with a basic example of how to use lineTwit but essentially it is 3 lines of code:-

<?php
 
  require_once(dirname(__FILE__) . '/lib/myTwit/lineMyTwit.class.php');
 
  $twitter = new lineMyTwit(array(
    'user' => 'USERNAME',
    'myTwitHeader' => true,
    'postLimit' => 5,
    'email' => 'EMAIL'
  ));
 
  echo $twitter->show();
?>

All you need to do to get lineTwit up and running is substitute USERNAME with your twitter username and EMAIL with your email address (used for any notification emails i.e. Twitter timeouts).

Parameters

A full list of the parameter you can set are shown below:-

Parameter Description
user Your twitter username
cacheFile The filename to use for the cacheFile (default: twitcache.txt)
cachExpire The time limit before twitter cache expires (default: 600 seconds)
postLimit The number of twitter posts to display (default: 20)
targetBlank Should links open in a new window? (default: false)
postClass The CSS class name to apply to each twitter post (default: false)
base_dir The directory the twitter cache files should be saved (default: ./)
myTwitHeader Do you want to show the twitter header above the twitter posts? (default: false)
show_follow_us_as The text to display as the follow us link underneath the posts? (default: Follow @[USERNAME] on Twitter)

[USERNAME] will be substituted for the actual twitter username. To disable the follow us link simply remove this option.

email The email address to send any notification emails (default: blank)

Acknowledgements

Many Thanks to both Ralph Slooten for allowing me create lineTwit based on his original and Line Digital for allowing me to share this with everyone.