Tweetlight
Display your latest tweets with pure JavaScript and PHP OAuth Library.
Demo
View demo here
Requirements
- PHP 5.4.0 or higher
- OpenSSL extension
Getting Started
# Get the latest snapshot $ git clone [email protected]:pinceladasdaweb/tweetlight.git
How to use?
Javascript initialization
Tweetlight is a Vanilla JS plugin with no dependencies. Include the tweetlight.min.js
before your </body>
tag:
<script src="path/to/tweetlight.min.js"></script>
And initialise it. For display a user timeline use:
Tweetlight({ username: 'pinceladasdaweb', // Twitter username container: '.timeline', // domNode to attach to showImageProfile: true, // Display image profile, default is false counter: 5, // Number of tweets to display onComplete: function() { console.log('Awesome APP'); // Callback to execute after fetch tweets. Not required, use if necessary. } });
For display hashtags use:
Tweetlight({ hashtag: '#html5', // Twitter hashtag container: '.hashtags', // domNode to attach to showImageProfile: true, // Display image profile, default is false counter: 5, // Number of tweets to display onComplete: function() { console.log('Awesome APP'); // Callback to execute after fetch tweets. Not required, use if necessary. } });
You can also load the plugin via AMD (require.js):
<script> require(["path/to/tweetlight.min.js"], function(Tweetlight) { Tweetlight({ username: 'pinceladasdaweb', // Twitter username container: '.timeline', // domNode to attach to showImageProfile: true, // Display image profile, default is false counter: 5, // Number of tweets to display onComplete: function() { console.log('Awesome APP'); // Callback to execute after fetch tweets. Not required, use if necessary. } }); }); </script>
HTML
In your HTML file where you want the tweets appear, insert a <ul>
tag with an id or class, to be used by JavaScript:
<ul class="timeline"></ul>
PHP
In the config.php config.php
file, complete the Twitter OAuth settings
define('CONSUMER_KEY', ''); define('CONSUMER_SECRET', ''); define('ACCESS_TOKEN', ''); define('ACCESS_TOKEN_SECRET', '');
Important Note
It is mandatory to file cacert.pem be on the same level/directory that Codebird.class.php file because Twitter requires secure connections in their API.
Browser support
Edge 14+ ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ |
Contributing
Check CONTRIBUTING.md for more information.
History
Check Releases for detailed changelog.