Display your latest tweets with pure JavaScript and PHP OAuth Library.
1 - 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>
2 - Paste right before your page's closing </body>
tag:
<script type="text/javascript" src="path/to/tweetlight.min.js"></script>
3 - From within a script tag or a JS file:
3.1 - For display a user timeline use:
Tweetlight.init({
username: 'pinceladasdaweb', // Twitter username
container: '.timeline', // domNode to attach to
counter: 5, // Number of tweets to display
onComplete: function() {
console.log('Awesome APP'); // Callback to execute after fetch tweets. Not required, use if necessary.
}
});
3.2 - For display hashtags use:
Tweetlight.init({
hashtag: '#html5', // Twitter hashtag
container: '.hashtags', // domNode to attach to
counter: 5, // Number of tweets to display
onComplete: function() {
console.log('Awesome APP'); // Callback to execute after fetch tweets. Not required, use if necessary.
}
});
3.3 - You can also load the script via AMD:
require(["/path/to/tweetlight.min"], function(Tweetlight) {
Tweetlight.init({
username: 'pinceladasdaweb',
container: '.timeline',
counter: 5
});
});
4 - In the config.php config.php
file, complete the Twitter OAuth settings
$CONSUMER_KEY = '';
$CONSUMER_SECRET = '';
$ACCESS_TOKEN = '';
$ACCESS_TOKEN_SECRET = '';
It is mandatory to file cacert.pem be on the same level/directory that codebird.php file because Twitter requires secure connections in their API.
![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|
IE 8+ ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ |
Check CONTRIBUTING.md for more information.
Check Releases for detailed changelog.