A few updates to MODX TwitterX as it becomes v1.0

I have just committed some changes to MODX extra TwitterX which now includes the ability to do basic searches, specify multiple screen_names and several bug fixes. Here's a quick summary of what's updated.

TwitterX

TwitterX is a MODX extra that loads Twitter statuses, timelines and basic Twitter searches by using the new (and very annoying) Twitter 1.1 API.

View the previous article on TwitterX

Multiple users using &screen_name

Thanks to Huub van der Voort (@hvoort), TwitterX now supports multiple screen_name values. This can be done by specifying a comma-separated list of Twitter usernames:

..
&screen_name=`Qodo,Microsoft`
..

This still supports single screen_names should you only want one. By not specifying a screen_name, it defaults to the user that created the API keys.

Basic Twitter Searches

TwitterX has been updated to now support basic Twitter searches by using the new parameter &search. When using this parameter, screen_name and timeline are ignored.

..
&search=`MODX`
..

This query will be cached as before but can be run much more frequently as this type of query doesn't use the API authentication so is not restricted by the Twitter request limitations. Here's an example of how this looks:

    Bringing in multiple feeds

    Something not mentioned in the last update is that TwitterX now allows you to bring in multiple feeds in separate calls. This can be done by specifying a unique value for &cache_id. TwitterX caches the Twitter data by using the resource ID and if you have more than one TwitterX call on one page, it will think it has already cached the data and will show the first one multiple times. Get around this by adding a unique id for each snippet call:

    ..
    &cache_id=`TwitterSearch1`
    ..
    ..
    &cache_id=`TwitterSearch2`
    ..

    Bug fixes

    • An error in the code was preventing the snippet from outputting errors. This has been corrected and should let you know if there was an error when trying to load the Twitter data.
    • A problem reported by Sean Lang meant that Twitter topic links where not working correctly and creating 404s because Twitter changed the URL.

    Comments 7

    1. Heelo Steward,

      great Plugin! But I have following error on my development area:

      Notice: Undefined property: stdClass::$from_user_name in D:\www\xxx\core\cache\includes\elements\modsnippet\150.include.cache.php on line 209


      It runs on XAMPP 1.8.1, with PHP 5.4.7, mySQL 5.

      Do you have an idea? Florian
    2. This was changed recently to only use the ID if you didn't specify a cache_id. Best option is to specify an ID and it will only call the Twitter API once. qodo
    3. Would using a common cache cache_id (such as the same value as screen_name) result in shared cacheing (not hitting twitter api for same thing on other pages, within the cache timelimit). I ask because it looks like the data is cached as $cache_id but looked up as $cache_id . '_' . $modx->resource->id JP DeVries
    4. New version available http://modx.com/extras/package/twitterx qodo
    5. Cheers Stewart your efforts are much appreciated! Tim Banks
    6. Yes, sorry. This has been fixed and was caused by using the 1.0 API instead of 1.1. Trying to upload to MODX although there is a problem with login so will take a while. Quick fix TwitterX snippet after line 114 add:

      $twitteroauth->host = "https://api.twitter.com/1.1/";
      qodo
    7. The extra seems to have stopped working on about 8 of our sites. Isn't TwitterX API v1.1 compliant? Could the Twitter drop for API v1 have effected this some how? https://dev.twitter.com/blog/api-v1-is-retired Tim Banks
    1. 1

    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>