Sorry, my site is very outdated – a new one is coming soon!

TwitterX: MODX extra for Twitter feeds using API 1.1

DISCONTINUED: As Twitter no longer offers a free API to access tweet information, this extra is now discontinued and no longer supported. Thanks for using it.


Updated 01/12/2012 - Updated to allow for different screen names
Updated 04/11/2012
- Added some new changes and fixes.
Updated 12/11/2012 - Updated documentation.
Updated 16/01/2013 - Updated and slight improvements.
Updated 21/01/2013 - Added more options (thanks to sepiariver)
Updated 23/04/2013 - View the article here for more details, article below updated to reflect changes
Updated 12/06/2013 - Updated to use the 1.1 API (as it should have been) and a few other little things. Some things will no longer work on the 1.1 API.
Updated 12/01/2014- Added option to exclude_replies and small bug fix

View a demo on the homepage Download TwitterX

Getting started

  1. To get started, install the package using Package Manager in MODX. You will then need to create a Twitter app here:

  2. Here create a new application by filling in the values required. Leave callback empty.

  3. How to create an application in Twitter

  4. Once you've created your application you will see there is a new API Key and API Secret.

    Your new twitter app will have an API key and API secret

  5. You will see a section called Your access token. Here you need to click Create my access token and the page will refresh with your new token,

    Create a new access token in your new twitter app

  6. Final step is to authorise your domain. I'm not 100% sure if this is needed but I was getting error message until I did this. Here you want to enter the domain of your site that is accessing the feed.

    How to create an application in Twitter


Once you've created your new application, have the necessary tokens and have authorised your domain you call the TwitterX snippet which will load your statuses using the details you have just generated:



  • twitter_consumer_key - your twitter consumer token (REQUIRED)
  • twitter_consumer_secret - your twitter consumer secret (REQUIRED)
  • twitter_access_token - your twitter access token (REQUIRED)
  • twitter_access_token_secret - your twitter access token secret (REQUIRED)
  • limit - limit how many statuses to display (default: 5)
  • timeline - which twitter timeline to load (default: user_timeline)
  • chunk - which chunk to load when rendering the statuses (default: TwitterXTpl)
  • cache - how many seconds to cache the twitter data feed (default: 7200)
  • screen_name - which user(s) you would like to load (comma separated) thanks to @hvoort
  • include_rts - should this include retweets (default: 1)
  • exclude_replies - should this exclude replies (default: 0)
  • cache_id - unique ID for caching in case you want to view multiple feeds or different feeds (default: TwitterX)
  • toPlaceholder - a placeholder ID if you want to use content as a placeholder instead of outputting directly (default: '')
  • search - search Twitter using a search value. When using this parameter, screen_name and timeline are ignored. (example: &search=`MODX`)

Loading timelines

The snippet defaults to user_time line but you can load any of these:

  • public_timeline
  • friends_timeline
  • user_timeline
  • home_timeline
  • mentions
  • retweeted_by_me this is no longer available in the 1.1 API!
  • retweeted_to_me
  • retweets_of_me

Searching Twitter

TwitterX now supports basic Twitter searches using the &search parameter:


When using this parameter, screen_name and timeline are ignored.


Use this snippet in your chunk placeholders to format the status text and automatically link any search, usernames or topics:


Chunk options

The package comes with a chunk for displaying the statuses called TwitterXTpl. You can customise this by using the following placeholders:

  • created_at - date status was created
  • source - source of the Tweet (application like web, iOS etc)
  • id - status id on Twitter
  • text - status main text
  • name - Twitter name
  • screen_name - Twitter username
  • profile_image_url - Twitter avatar image url for this user
  • location - This users location
  • url - This users URL (if specified)
  • description - This users profile information

And for retweets, you can use these

  • retweet_created_at - date status was created
  • retweet_source - source of the Tweet (application like web, iOS etc)
  • retweet_id - status id on timeline
  • retweet_id_str - status id on Twitter (
  • retweet_text - status main text
  • retweet_name - Twitter name
  • retweet_screen_name - Twitter username
  • retweet_profile_image_url - Twitter avatar image url for this user
  • retweet_location - This users location
  • retweet_url - This users URL (if specified)
  • retweet_description - This users profile information


If you find any bugs or would like some help, please feel free to get in touch on GitHub:

Comments 57

  1. Laurent, thanks for the feedback and comments. I think your site must be using the class elsewhere so will update the package to check the class first!

    I will definitely add the id_str! qodo
  2. Hi,

    Fantastic snippet, just in time for my project too!

    in regards to my previous comment, I edited OAuth.php, wrapping the class declaration in a test:

    if(!class_exists(OAuthException)) {
    class OAuthException extends Exception {
    // pass

    and it works. I guess my PHP version must have a native OAuthException class? Or perhaps another snippet is creating it...

    In regards to the snippet itself, I have a suggestion; in my usage of this I have the requirement to link back to the actual tweet directly rather than the timeline, I found that adding the following:

    'id_str' => $j->id_str

    to the snippet in the call to get_chunk includes the id_str from which a url to the tweet can be generated

    Thought it might be useful to include this in a future version in case others have similar requirements. Laurent Mignot
  3. Hi,

    Excellent work, I'm getting 500 errors however, php is complaining about:
    Cannot redeclare class OAuthException in ....../core/components/twitterx/twitteroauth/twitteroauth/OAuth.php on line 8

    Any ideas? Laurent Mignot
  4. Hi Exside, The caching currently uses MODX and needs some testing to see if it updates quickly enough. I want to tweek this to allow for faster updates and other users feed like retweets etc. qodo
  5. Lol... I just spend a lot of time writing this myself and guess what, i also called it twitterX =P...but you did exactly what is left on my todo list (implement the whole oAuth shit)...because what my twitterX is doing is use the old 1.0 API to fetch data without authentification...

    what would be interesting to me, how do you solve caching of the results, which seems necessary because of 150 / 350 rate limits set by twitter....? exside
  6. Ow and it works for Rev. 2.1.1 ! Tim Banks
  7. This works really well. Thanks for sharing! Tim Banks
  1. 1
  2. 2
  3. 3

Got something to say?

Join the discussion! You know how these things work; enter your details and comments below and be heard.

  1. Allowed tags: <b><i><br>