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. Thanks Kevin, will sort this now and upload a new version :) qodo
  2. Love the plugin! I ran across an error. The &limit property was adding one to the number I specified. For example, I wanted 3 tweets, entered &limit=`3`, but 4 would show. Specify 2, and 3 would show.

    In the snippet, there's a line:

    // Request statuses 
    $options = array(
    'count' => $limit+1,
    'include_rts' => 1

    I removed the +1 and it now displays the correct number specified in &limit.

    Thanks for the plugin, it's great!
  3. Hi Sarah, what version are you using? 0.6 is the best. Do you get any errors in the server log?
    twitter_consumer_token_secret is a mistake that I haven't changed as it would break anyone upgrading. qodo
  4. Hi Stewart,

    I have changed back the 4th call to consumer_token_secret, but now the page loads blank (firebug console gives me 500 error) - this is my code:

    &twitter_consumer_key=`consumer key`
    &twitter_consumer_secret=`consumer secret`
    &twitter_access_token=`access token`
    &twitter_consumer_token_secret=`access secret key`
    &screen_name=`twitter username`

    Twitter gives me 2 consumer keys and 2 access keys and I have checked they are correct.

    Is there any reason why the secret access key is called
    instead? wouldn't twitter expect this to be access_token_secret?

    Thanks. Sarah
  5. Hi Sarah, that looks incorrect it is expecting 4 parameters:

    Make sure you are passing those 4 values! qodo
  6. Hi,

    I have tried to implement TwitterX on my ModX Rev 2.2.4 but get this error where tweets should be displayed:

    TwitterX Error: Could not load TwitterX as required values were not passed.

    I have the following call:

    &twitter_consumer_key=`as created`
    &twitter_consumer_secret=`as created`
    &twitter_access_token=`as created`
    &twitter_access_token_secret=`as created`
    &screen_name=`twitter username`

    Note: I have changed &twitter_consumer_token_secret= to &twitter_access_token_secret= as the consumer token was duplicate in the above code on here.

    Any help in finding a solution for the error greatfully received - finding a twitter feed that actually works is proving a mission! Thanks. Sarah
  7. Hi Louis, that's strange. Where are you testing this? If you are testing on a local environment you need to check that cURL is enabled as it is used to make the request. Let me know what you're testing on and I'll have a think. qodo
  8. Thank you Stewart for the Update. I still don't understand what I'm doing wrong, it's not working for me for some reason. This is what I've done.

    - Uninstalled the previous version and installed the 0.6 version.
    - added the following to the location where I want to show the tweets.
    &twitter_consumer_key=`The Key I got from creating the App as per instruction`
    &twitter_consumer_secret=`The Key I got from creating the App as per instruction`
    &twitter_access_token=`The token I got from creating the App as per instruction`
    &twitter_consumer_token_secret=`The token I got from creating the App as per instruction`
    &screen_name=`screen name for the tweeter account I want to display on the site`

    I have not touched the snippet nor the chunk, haven't modified any files at all and all I get is this "on twitter" with a hyperlink to Louis
  9. This has been submitted an approved now. Louis you can use &screen_name=`asdf` to load another user's tweets. You will need to download the latest version TwitterX 0.6pl qodo
  10. Hi Louis, I am making a change to it now that allows you to view any users status. I will post here when it is live. It's strange that you are seeing .on twitter. Do you want to email me your code so I can look at it? qodo
  11. Hello,

    I'm trying to get this to work and I followed the instructions step by step but it's not doing what it's supposed to do. It's not loading my tweets, all I see is a line that says ".on twitter" and nothing else.

    I'm also wondering if you have to create an APP for every twitter account you want to fetch status for or if there's a way to fetch any twitter account's status you want.

    Thanks. Louis
  12. How do I get someone else's feeds to load instead of mine? I can't even get mine to load. All I get is ".on twitter" to display on my website. Louis
  13. Hi Paul, I have just submitted a new version so that might explain why it is down at the moment. You can download it here and then FTP it to your MODX /core/packages/ folder. Then use "Search for local packages". Let me know how you get on! qodo
  14. This looks great! However the download link on is broke for TwitterX, is there an alternative download location? Thanks. PaulG
  15. Hi Sanjuro. Currently this is not possible. It can only read one feed from Twitter at a time. qodo
  16. Jeremy, thanks for this. Will get it updated ASAP! qodo
  17. I just found the issue. Line 73 of the snippet needs to be changed from
    echo "TwitterX Error: Could not load TwitterX Twitter reponded with the error '" . $json['error'] . "'.";

    echo "TwitterX Error: Could not load TwitterX Twitter reponded with the error '" . $json->error . "'.";
  18. I am getting the following error:
    Fatal error: Cannot use object of type stdClass as array in /FULL/PATH/TO/core/cache/includes/elements/modsnippet/9.include.cache.php on line 78

    Any idea what is causing this? Jeremy
  19. Stewart Orr,
    then does not show my tweets (user_timeline)...
    I want to display my tweets (&timeline=`user_timeline`) and mentions (&timeline=`mentions`)
  20. Sanjuro, for mentions try this: -
  21. Stewart Orr, I want to display my tweets and mentions
    p.s. please excuse my bad English... Sanjuro
  22. Sajuro, try using
  23. Hi,
    how to set up user_timeline + mentions? Sanjuro
  24. Hi Blair, I've just noticed I haven't updated the documentation on this page. Try using the placeholder retweet_text for the retweet. This should be without the ellipse. qodo
  25. So, unless I'm doing something wrong, I'm noticing that the 'user_timeline' option doesn't include retweets, nor any method of including them. I modified my installed copy of TwitterX, changing the line
    $json = $twitteroauth->get('statuses/' . $timeline);

    $json = $twitteroauth->get('statuses/' . $timeline, array('include_rts' => true));

    Which works, save that the retweets are truncated with an ellipses. I'll fiddle with it some more to see what I come up with. Blair Miller
  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>