Adding a Twitter Feed
Last updated Oct 27th, 2020 | Page history | Improve this page | Report an issue
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$306 per month—let's make that $500!
Learn moreDo NOT use this method for showing a twitter feed! Twitter has deprecated their API v1.0 (which this tutorial makes use of) and it will be disabled COMPLETELY starting June 11th. See https://dev.twitter.com/blog/api-blackout-testing-continues-may-22-2013 for more information from Twitter.
You can use JSONDerulo (https://modx.com/extras/package/jsonderulo) or TwitterX (https://modx.com/extras/package/twitterx) to show twitter feeds instead.
Adding Twitter to Your Site¶
This tutorial shows you how to add Twitter feeds to your site through getFeed.
Adding the getFeed Call¶
First off, after you've downloaded and installed getFeed, place this Snippet call wherever you want the Twitter feed to show up:
<ul>
[[!getFeed?
&url=`http://twitter.com/statuses/user_timeline/123456789.rss`
&tpl=`twitterFeedTpl`
&limit=`3`
]]
</ul>
Make sure to change the number there to your own Twitter user ID or username.
So we're calling this snippet uncached, and pointing it to our public Twitter timeline. Then we only want the latest 3 tweets. From there, create a 'twitterFeedTpl' Chunk, and put this in it:
<div class="tweet">
<p>[[+description]]
<br /><a href="[[+link]]">[[+pubDate:ago]]</a> via [[+twitter.source]]</p>
</div>
There we go! Our Twitter feed now shows up. Note we have our :ago filter, which formats the date in a nice, "X minutes, X hours" ago format.
Note that the placeholder to use for the date (as well as any other placeholders) can depend on the feed. Check the raw XML source of a feed to see in what item the data is stored, and use that.
See Also¶
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$306 per month—let's make that $500!
Learn more