Display your latest tweets with pure JavaScript and PHP OAuth Library.
View demo here
- PHP 5.4.0 or higher
- OpenSSL extension
# Get the latest snapshot
$ git clone [email protected]:pinceladasdaweb/tweetlight.git
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>
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>
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', '');
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.
Edge 14+ ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ |
Check CONTRIBUTING.md for more information.
Check Releases for detailed changelog.