Auto post to Twitter when publishing in MODx

I was reading the MODx forums and came across an idea/request for the ability to auto post to Twitter when you publish a new document. Having spent some time going over Twitters api I knew this would be a pretty easy task, so I wrote a quick plugin to make it work.

Features

Install Instructions

  1. Download the files from the link in the right side-bar.

  2. Extract the files into your MODx install directory (i.e. assets/plugins/TwitterStatus).

  3. Copy the contents of the file TwitterStatus.plugin.php into a new plugin named TwitterStatus.

  4. In the comments in the file TwitterStatus.plugin.php there are configuration parameters. Copy these parameters into Plugin Configuration textarea.

  5. Tab/Click out of the configuration field and update the configuration options with your custom settings. If you want to use Bit.ly you must specify your account information (this is now in the BitlyService.class.php file).

  6. On system events tab check the event OnDocPublished.

  7. Save the plugin and you are now ready to use it.

Notes

Due to how MODx handles the event OnDocPublished, the only way to get this to fire is to right click a document in the tree and select publish. If you save/edit a document the event will not be fired. For this plugin this is actually a good thing so that you do not end up with multiple tweets for the same page.

I am thinking about adding a template variable to each page that gets set when you update your Twitter status. This would then be another check to prevent a document from being sent to Twitter more than once.

Any additional suggestions/feature request are welcome. I have not done a lot of testing with this, but have it up and running on my site.

Update - 04/07/2009 - v1.1

  • Added support for Url shorteners: Is.gd & Digg
  • Added fail over to file_get_contents for servers without cUrl (needs testing)
  • Seperated the URL shorteners into seperate classes so it is easy to plugin new ones.
Comments
If you have trouble reading the code, click on the code itself to generate a new random code.
Security Code:
 
Required fields are marked with *.
Showing comments 1 to 10 of 21 | Next | Last
Comment

21

nice blog aatos1 Sat July 03, 2010, 21:28:21

Cool blog really ):

Comment

20

nice blog aatos Sat July 03, 2010, 21:27:41

Cool blog

Comment

19

nice ulpu Sat July 03, 2010, 21:27:11

nice <a href="http://www.google.com">Google</a>

Comment

18

Twitter Status question Antony Jones Wed May 12, 2010, 16:06:38

Hi,
First of all I wanted to thankyou for providing this great plugin for modx.

I am trying to replace the placeholder with a template variable, or alternatively add a TV to the "tweet template" area. Nothing I do seems to work however, any ideas?

Thanks,

Ant.

Comment

17

Tv´s ersao Mon May 10, 2010, 14:00:07

As I replaced the [pageTitle] for a TV

thanks

Comment

16

Sweet plugin hosting professionals Mon April 12, 2010, 08:01:31

Once again, great job Kyle. Thanks for this nice plugin.

Comment

15

Thanks! Matt Sun March 14, 2010, 16:44:30

This looks like a sweet plugin. Running Evolution, and this will be very easy to customize. Thanks a lot!

Comment

14

Adding Twitter Status to my site Michael Sat February 27, 2010, 03:30:11

Hi I have followed your instruction above I was wondering what call I have to add to me chunk to allow Twitter Status to appear similar to the one you have on your site on the top right...

Thanks for this plugin i hope i can get it to work like yours

Comment

13

Thx style-nes Wed February 24, 2010, 23:00:08

Thx for plugins! Nice work!

Comment

12

Select a Blog folder? Simon Brown Thu February 18, 2010, 07:30:01

Is it possible to tell the Plugin to only publish twitter feeds from a desired directory?... Example on publish twitter feeds from the Blog directory in MODx

Showing comments 1 to 10 of 21 | Next | Last
logoLeaving tracks across the web.