If you have any questions that are beyond the scope of this help file, please feel free to email via my user page contact form. Thanks so much!
The main required file is twitterAPI.php, this is the library that gets the timeline statuses from Twitter and optionally caches them localy. The vertical timeline requires all the files in the css, images folders, too. On top of that, the horizontal timeline uses JavaScript thus requiring all the files in the js folder, too. If you'd like to obtain just the text version of the statuses you can use only the twitterAPI.php library and discard the other files.
After you copied the files to your project (locally or by FTP), include the twitterAPI.php (with the require function) and initialize the library - follow one of the examples for the exact markup and style as in the demo. Here is an example of initializing the library and getting only the text version of the tweets:
<?php require("twitterAPI.php"); $twitterAPI = new TwitterFeed(); $twitterAPI->->init('liviucerchez',20); // parameters explained below $tweets = $twitterAPI->getTweets(); // the part below is an example of getting the text version of the tweets foreach($tweets as $tweet) : echo $tweet->text . "<br/>"; endforeach; ?>
The vertical timeline chould be displayed using the following suggested code (please see the source code of this file for a more detailed version):
<link rel="stylesheet" href="css/twitter-timeline.css" media="all" /> // place it in the <head> part
<ul class="twitter-timeline twitter-timeline-vertical clearfix"> <?php foreach($tweets as $tweet) : ?> <li> <p class="tweet clearfix"> <a href="https://twitter.com/<?php echo $tweet->user->screen_name; ?>" class="avatar"> <img src="<?php echo $tweet->user->profile_image_url; ?>" alt="" /> </a> <strong class="name"><?php echo $tweet->user->name; ?></strong> <?php echo $tweet->html; ?> <br /> <span class="date"><?php echo $tweet->updated; ?></span> </p> </li> <?php endforeach; ?> </ul>
The horizontal timeline has a similar structure. Please make sure you include the JavaScript in order for this carousel timeline to work properly.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.twitterslide.js"></script> <script> $(function(){ $('.twitter-timeline-horizontal').twitterslide({ imageW : 328, minItems : 1, margin : 15 }); }); </script>
<div class="twitter-timeline twitter-timeline-horizontal clearfix"> <div class="ts-carousel"> <ul> // same code for <li> elements from the vertical timeline example </ul> </div> </div>
Twitter Timeline can be customized easily once initialized like this:
<?php require("twitterAPI.php"); $API = new TwitterFeed(); ?>
Function | Description | |
---|---|---|
$API->init($user,$limit,$retweets,$replies); | Obtains the timeline for the current user (caches it if cache file enabled) $user - Twitter username (required) $limit - Number of tweets to fetch (optional, default: 6) $retweets - Determine if retweets should be included in the timeline (optional, default: TRUE) $replies - Determine if replies should be included in the timeline (optional, default: FALSE) |
|
$API->initlist($user,$list,$limit,$retweets,$replies); | Obtains the timeline of a user's list (caches it if cache file enabled) $user - Twitter username (required) $list - List slug name (required) $limit - Number of tweets to fetch (optional, default: 6) $retweets - Determine if retweets should be included in the timeline (optional, default: TRUE) $replies - Determine if replies should be included in the timeline (optional, default: FALSE) |
|
$API->getTweets(); | Returns the tweets after initialization. More details about the results parameters can be found here. | |
$API->setCachingOptions($file,$lifetime); | Sets the cache file and lifetime in seconds of the cached timeline. Defaults: "cache/%s.json" and 600 | |
$API->setCachingDirectory($path); | Sets the relative path of the cache file. Default: null - current directory | |
$API->enableCaching($enabled); | Determine if caching system is enabled. Default: true | |
$API->clearCache(); | Clears cache if it exists. | |
$API->time_since($date); | Returns a twitter style date (ex: 3 minutes ago). | |
$API->statusUrlConverter($text); | Returns a html status with generated links for profiles and hashtags. | |
Make sure you check out the twitterAPI.php and the examples. |
The horizontal timeline can be customized by passing the following options in JavaScript:
$('.twitter-timeline-horizontal').twitterslide({ // options placed here });
Option | Default | Description |
---|---|---|
slideWidth | 220 (required) | Sets the width of each slide/tweet. |
speed | 300 | Sets the animation speed when sliding to next page of timeline (in miliseconds). |
easing | - | Sets the animation easing effect used when sliding to next page of timeline. |
margin | 5 | Determined the margin between slides. |
minItems | 1 | Sets the minimum number of items to show. When we resize the window, this will make sure minItems are always shown. |
current | 1 | Sets the index of the current item. When we resize the window, the carousel will make sure this item is visible . |
Note: The library uses the user_timeline API function, you should check it out to see what this request is outputting.
Once again, thank you so much for purchasing this script. As I said at the beginning, I'd be glad to help you if you have any issues or concerns related to this script. No guarantees, but I'll do my best to assist.