====== AutoTweet Plugin ====== ---- plugin ---- description: The autotweet plugin automatically posts tweets to your Twitter App when specific pages are changed. author : Jannes Drost-Tenfelde email : info@drost-tenfelde.de type : Action, Syntax lastupdate : 2011-10-06 compatible : 2011-05-25, 2012-01-25, 2013-12-08, 2014-05-05 depends : conflicts : similar : tags : twitter, changelog, feed downloadurl: https://github.com/jdtProjects/dokuwiki/raw/master/published/plugin_autotweet_1_0.zip bugtracker : sourcerepo : https://github.com/jdtProjects/dokuwiki/tree/master/autotweet donationurl: http://www.drost-tenfelde.de/?id=donate screenshot_img: ---- This plugin automatically posts Tweets to your Twitter via the [[https://oauth.net/|oAuth authentication protocol]] when specific pages are changed. You can specify which page updates are sent, by including the ''%%~~AUTOTWEET:~~%%'' syntax in these specific pages. The plugin uses the Abraham Williams OAuth for Twitter PHP Library. ===== Requirements ===== ==== cURL Extension ==== :!: Important :!: It is **mandatory** that you have installed the [[phpfn>curl|cURL Extension]] for PHP. You can check if the extension is installed using the following code: if ( function_exists('curl_init') ) { echo 'cURL is installed'; } else { echo 'cURL is NOT installed'; } ==== Twitter App ==== The plugin communicates with Twitter using the [[https://oauth.net/|oAuth authentication protocol]]. This protocol requires authentication keys that you will get by setting up a Twitter App. === Step 1: Setup Twitter App === Head to Twitter and [[https://apps.twitter.com/app/new|set up an application]]. :!: Important :!: Make sure you selected "Read & Write" acces. === Step 2: Get the security parameters === Once you've created your Twitter application [[https://apps.twitter.com/|get the parameters for authentication]]. ^ Parameter ^ Comments ^ | 'Consumer key' | This is displayed in the section **oAuth**. | | 'Consumer secret' | This is displayed in the section **oAuth**. | | 'Access token' | This is displayed in the section **Your access token**. | | 'Access token secret' | This is displayed in the section **Your access token**. | These parameters must be used in the [[#configuration_and_settings|configuration]] of the plugin, so that the plugin can communicate with Twitter. Optionally, you can use [[#syntax|syntax]] parameters to specify alternate Twitter Apps for specific pages. This, however, is optional. ===== Installation ===== Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually. ===== How it works ===== If you wish to track changes for a specific page, add the ''%%~~AUTOTWEET:~~%%'' syntax to that page. If a page containing the ''%%~~AUTOTWEET:~~%%'' syntax is edited, the [[devel:metadata#data_structure|change_log]] information is used to assemble a message, which is then forwarded to the configured Twitter App as a Tweet. ===== Examples/Usage ===== ~~AUTOTWEET:~~ If you wish to use alternate Twitter Apps for specific pages, you can optionally add [[#syntax|syntax]] parameters. ~~AUTOTWEET:consumer_key=&consumer_secret=&access_token=&access_token_secret=~~ ===== Syntax ===== You can use the parameters to overwrite the configuration settings for specific pages. This is not normally necessary. ~~AUTOTWEET:key=value&..key=value~~ | ''key'' | the parameter key to set | optional | | ''value'' | the parameter value to set | optional | You can set more than one element at once by using an ''&'' delimiter. Available parameters: ^ Key ^ Type ^ Comments ^ ^ | consumer_key | string | **Consumer Key** of the Twitter App. Overwrites configuration parameter 'consumer_key'. | optional | | consumer_secret | string | **Consumer Secret** of the Twitter App. Overwrites configuration parameter 'consumer_secret'. | optional | | access_token | string | **Access Token** of the Twitter App. Overwrites configuration parameter 'access_token'. | optional | | access_token_secret | string | **Access Token Secret** of the Twitter App. Overwrites configuration parameter 'access_token_secret'. | optional | **Note**: Normally you would use the same settings for all pages, in which case the syntax %%~~AUTOTWEET:~~%% is sufficient. Default usage: ~~AUTOTWEET:~~ ===== Configuration and Settings ===== ^ Key ^ Type ^ Comments ^ ^ | consumer_key | string | **Consumer Key** of the Twitter App. | **required** | | consumer_secret | string | **Consumer Secret** of the Twitter App. | **required** | | access_token | string | **Access Token** of the Twitter App. | **required** | | access_token_secret | string | **Access Token Secret** of the Twitter App. | **required** | | message_template | string | Message template that will be filled out and used to send a Tweet to the Twitter App. | **required** | | date_format | string | [[phpfn>strftime|Date format]] of the {date} field used in the message template. | **required** | ===== Message Template ===== For convenience you can change the formatting of the tweet sent to Twitter via the 'message_template' [[#configuration_and_settings|configuration]] parameter. The fields in the message will be replaced by the plugin. Default: {type} {page} - {summary} {user} Example (including link to the page): {date} {type} http://www.dokuwiki.org/{page} - {summary} @{user} ==== Template fields ==== ^ Tag ^ Comments | | %%{type}%% | Type of edit (//Create//, //Edit//, //Minor Edit//, //Delete// or //Revert//) | | %%{date}%% | Date of the last change. The format can be setup via [[#configuration_and_settings|Configuration and Settings]] | | %%{page}%% | ID of the page | | %%{summary}%% | Summary of the editor. | | %%{user}%% | User name of the user editing. | | %%{extra}%% | Extra data, used for storing the revision (timestamp) in the case of a revert. | ===== Development ===== === Change Log === * **2011-10-06**: [[http://www.drost-tenfelde.de/lib/exe/fetch.php?media=dokuwiki:plugin_autotweet_1_0.zip|Version 1.0]] * Initial release === Known Bugs and Issues === * **2014-05-27**: Change **twitteroauth.php** from //1// to //1.1// and it works with latest dokuwiki-release //2014-05-05 "Ponder Stibbons"//public $host = "https://api.twitter.com/1.1/"; * **2013-12-28**: Change **twitteroauth.php** from //1// to //1.1// and it works with latest dokuwiki-release //2013-12-08 "Binky"//public $host = "https://api.twitter.com/1.1/"; * I tried step by step, double check but doesnot work, is there a debug mode somehere? * It works now (just had to wait a couple of days) === ToDo/Wish List === * I am considering adding a configuration parameter 'track_all_changes'. If the parameter is set, all pages will be regarded by the plugin and tweets will be sent for all page changes, regardless of an %%~~AUTOTWEET:~~%% syntax being present or not. * + 1 * Thanks for this plugin! I am wondering whether it would be possible to set it up so that rather than tweet from a particular page it tweets from a particular NS. I imagine this would not be too hard to add in...I may try to do it myself but would probably bumble quite a bit. * It were great, if tweets only sent, when the checkbox "small changes" is unchecked. ===== FAQ ===== ===== Discussion ===== Hello... ¿how can I launch a tweet each time a new page is created? (I'm configuring a blog, and I need to comunicate new entries in the blog) (%%www.laterriblecorduradelidiota.es%%)