Extension:Community Twitter

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual
Crystal Clear action run.png
Community Twitter

Release status: beta

Community twitter.png
Implementation Special page, Database
Description Gives a group of users the opportunity to twitter using one or more community twitter accounts. Users have the ability to tweet, retweet and delete tweets.
Author(s) Basti(talk), FastLizard4(talk), RAN1(talk)
Latest version 0.3.0 (17 May 2013)
MediaWiki 1.17+
PHP 5.2+
License GPLv2
Download
0.2.2: Initial release + some minor readme fixes

0.2.3: Better/fixed error handling 0.3.0: Extension migrated to Wikimedia Code Review, updates for internationalization and translation. 0.3.1: Extension's CSS and JavaScript ported to ResourceLoader

Parameters

ctTableName, ctDefaultAccount, ctAllowedGroup, ctDisplayCoordinates, ctLat, ctLong, ctAliases

Hooks used
PersonalUrls

Translate the Community Twitter extension if it is available at translatewiki.net

Check usage and version matrix; code metrics

The Community Twitter Extension gives a defined group of users the opportunity to twitter using one or more community twitter accounts. Users have the ability to tweet, retweet and delete tweets.

If you manage a smaller wiki, you have the ability to register an app for each user, so users identify themselves via the app name (see e.g. http://twitter.com/Hickernews/status/24840953797). Applications must link to the corresponding user page in the wiki, so each user can only delete his own tweets.


German speaking users can find installation instructions here.

Todo[edit | edit source]

  • Record all tweets in a DB table to be able to remember the author of the tweet (currently for small Wikis only)
  • Introduce some other kind of signature, maybe something like "^xy" as the last three characters in a tweet


Installation Instructions[edit | edit source]

1. Register a Twitter account (or more) if you haven't already done.

2. Register an application/applications on https://dev.twitter.com with read & write access. Choose what fits your needs:

  • If you maintain a big wiki with lots of users using Community Twitter:
Register one app. The name of the application gets displayed under the tweet. You might want to call it like the wiki.
  • If you maintain a manageable wiki with just a few users using Community Twitter:
Register an application for each user who should be able to tweet. The name of the application gets displayed under the tweet. Call it like the corresponding user and link to the user page (NOTE: this must be done for the extension to link the user to his tweets). This is a cool way to have kind of a signature in order to guard against abuse. Users can only delete their own tweets.

3. Create a new table in your SQL-DB by executing the following SQL-Code:

--
-- Table structure for table `community_twitter`
--
 
CREATE TABLE IF NOT EXISTS `community_twitter` (
  `user_id` INT(11) NOT NULL,
  `app_name` text NOT NULL,
  `consumer_key` text NOT NULL,
  `consumer_secret` text NOT NULL,
  `access_token` text NOT NULL,
  `access_token_secret` text NOT NULL,
  `active` SMALLINT(6) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Note: If you change the table name, you have to adapt the LocalSettings.php (in step 9).


4. Insert application data in the SQL table (e.g. via phpMyAdmin), depending on what you chose in the second step:

  • as user_id fill in the id of the user, who will be twittering via this app (look up in "user" table). If you chose to register just one app, set this to 0.
(Note: joint and individual accounts must not be merged!)
  • as app_name a self-defined name identifying the twitter account (has to be consistent; if you run only one Twitter account, it's everywhere the same)
  • consumer_key is the Consumer Key on dev.twitter.com for your app
  • consumer_secret is the Consumer Secret on dev.twitter.com for your app
  • access_token is the Access Token on dev.twitter.com for your app
  • access_token_secret is the Access Token Secret on dev.twitter.com for your app
  • set active whether the user should be able to tweet or not (0=false, 1=true)

Note: In case you registered two Twitter accounts, just connect the registered application to both accounts (see e.g. http://jeffmiller.github.com/2010/05/31/twitter-from-the-command-line-in-python-using-oauth).

consumer_key and consumer_secret should be the same for each Twitter account in this case, only access_token and access_token_secret vary!


5. Create advice and description wiki pages. Their titles are defined in Twitter.i18n.php ("twitter_advice_template" and "twitter_description_template").

These pages get displayed above (description) and under (advice) the Tweet! section.

6. Download the extension into your MediaWiki installation (see below).

7. Append the following configs to your LocalSettings.php and customize them:

# Community Twitter Extension (settings first, THEN include)
// DB-Table holding API keys and allowed users
$ctTableName = "community_twitter";
// Default Twitter account (has to be similar to the app_name column in the SQL-Table; e.g. used for linking tweets of different accounts)
$ctDefaultAccount = "Hickernews";
// Make special page accessible to this group (see http://www.mediawiki.org/wiki/Manual:User_rights#List_of_Groups) (creating a new group might make sense)
$ctAllowedGroup = "sysop";
// Set if you want to transmit coordinates with your tweets (has to be enabled in Twitter settings to be displayed)
$ctDisplayCoordinates = true;
// Latitude (ignored when $ctDisplayCoordinates is set to false)
$ctLat = "52.161579";
// Longitude (ignored when $ctDisplayCoordinates is set to false)
$ctLong = "9.957183";
// Aliases for /Special:Twitter
$ctAliases = array("Hickernews");
// If this is not the location you installed the extension to, you probably have to edit Twitter_body.php
require_once("extensions/CommunityTwitter/CommunityTwitter.php");

8. That's it.

Downloading[edit | edit source]

The extension can be retrieved directly from Git [?]:

  • Browse code
  • Some extensions have tags for stable releases.
  • Each branch is associated with a past MediaWiki release. There is also a "master" branch containing the latest alpha version (might require an alpha version of MediaWiki).

Extract the snapshot and place it in the extensions/CommunityTwitter/ directory of your MediaWiki installation.

If you are familiar with git and have shell access to your server, you can also obtain the extension as follows:

cd extensions/
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/CommunityTwitter.git