TXP Plugins
arc_twitter :: Feb 23, 08:28 PM
arc_twitter provides access to your Twitter account through both the admin interface and the public side of your site. Update Twitter when you post a new article (with article-by-article opt out option), update and view your Twitter feed through the admin Twitter tab, and display Twitter feeds on your site.
Requirements:-
- Textpattern 4.2+
- PHP 5 and cURL
Installation
To install go to the ‘plugins’ tab under ‘admin’ and paste the plugin code into the ‘Install plugin’ box, ‘upload’ and then ‘install’. Finally activate the plugin.
Before you start using arc_twitter you will need to make sure that the cache directory is writable. See the ‘Caching’ subsection below for further information.
arc_twitter should now be ready for use on the public-side of your site.
To unlock the admin features of this plugin you will need to set the plugins preferences using your Twitter account login. You will find these under the advanced ‘preferences’ under ‘admin’. Without providing a valid username and corresponding password you will not be able to update Twitter through Textpattern’s admin area.
Uninstall
To uninstall arc_twitter simply delete the plugin from the ‘Plugins’ tab. This will remove the plugin code, delete related preferences and drop the arc_twitter table from your Textpattern database.
The arc_twitter tag
Syntax
<txp:arc_twitter user="drmonkeyninja" />
Usage
| Attribute | Description | Default | Example |
|---|---|---|---|
| user | Twitter user name | unset | user="drmonkeyninja" |
| password | Your Twitter password (not required for public updates) | unset | |
| limit | Maximum number of tweets to display (max. 200) | 10 | limit="25" |
| dateformat | Format that update dates will appear as | Archive date format | dateformat="%b %Oe, %I:%M %p" |
| label | Label for the top of the list | no label | label="My Twitter timeline" |
| labeltag | Independent wraptag for label | unset | labeltag="h3" |
| break | HTML tag (without brackets), or string, used to separate the updates | li | break="br" |
| wraptag | HTML tag to be used as the wraptag, without brackets | unset | wraptag="ul" |
| class | CSS class attribute for wraptag | arc_twitter | class="twitter" |
The arc_twitter_search tag
Syntax
<txp:arc_twitter_search hashtags="txp" />
Usage
| Attribute | Description | Default | Example |
|---|---|---|---|
| search | Comma separated list of search words | unset | search="txp,textpattern" |
| hashtags | Comma separated list of hashtags to search for (not including the hash) | unset | hashtags="txp,textpattern" |
| reply | Username of tweets in reply to | unset | reply="twitter" |
| mention | Username of user mentioned in tweets (i.e. tweets containing @username) | unset | mention="twitter" |
| limit | Maximum number of tweets to display (max. 200) | 10 | limit="25" |
| dateformat | Format that update dates will appear as | Archive date format | dateformat="%b %Oe, %I:%M %p" |
| label | Label for the top of the list | no label | |
| labeltag | Independent wraptag for label | unset | |
| break | HTML tag (without brackets), or string, used to separate the updates | li | |
| wraptag | HTML tag to be used as the wraptag, without brackets | unset | |
| class | CSS class attribute for wraptag | arc_twitter_search |
Example usage
<txp:arc_twitter_search search="plugin" hashtags="txp,textpattern" limit="25" />
Produces a list of tweets containing the word ‘plugin’ and the hashtags ‘#txp’ and ‘#textpattern’. The tag will return a maximum of 25 tweets.
Caching
In order to prevent excessive repeatitive calls to the Twitter website it is recommended to cache results. Twitter limits the number of calls through the API, and continuous calls will result in Twitter closing to further requests. By default, arc_twitter caches for 30 minute intervals.
| Attribute | Description | Default | Example |
|---|---|---|---|
| caching | ‘1’ to cache feed, ‘0’ to turn caching off (not recommended) | 1 | caching="1" |
| cache_dir | Absolute path to the cache directory (must be writable) | ||
| cache_time | Time in minutes that the cache files are stored before being refreshed | 5 | cache_time="30" |
The admin side of this plugin enforces caching, apart from when it is posting to Twitter (e.g. when posting or deleting an update).
Preferences
You can access the plugins core preferences from either the Preferences or Plugins tabs in admin. Setup your Twitter account login details (i.e. your username and password) and change the cache directory using arc_twitter’s preferences. Without providing your account login details the admin area features of this plugin will be inactive.
Tweeting articles
If you set your Twitter account username and password you will see the option to update Twitter everytime you create a new article. By default arc_twitter will post an update to Twitter including a shortened URL to your article. Only live and active articles will be sent to Twitter, i.e. articles posted in the future or as sticky articles will not be sent. If your article is successfully submitted to Twitter the update will appear in place of the Twitter option on the right-hand-side of the article edit screen.
Tweets are sent in the following format: Tweet prefix Article title Shortened URL Tweet suffix. You can change the prefix and suffix on an article-by-article basis by changing the tweet options under ‘Update Twitter’ on the article editor screen. The default Tweet prefix can be set under the arc_twitter preferences screen (the default on installation is “Just posted:”).
Please note that once an article has been tweeted the tweet cannot be edited.

The Twitter tab
Under the Extensions tab a new Twitter tab should appear once a Twitter username has been provided. From here you will be able to submit new Twitter updates, view basic account statistics, and check out your recent updates (including the option to delete your tweets). If no password has been set in preferences (see above) you will need to provide the valid password each time you update Twitter.

Change-log
- v0.2.2
- important fix to storage of Twitter IDs in database
- v0.2.1
- non-object bug fix
- v0.2
- Prefix and suffix article tweets using the “Twitter Update” options
- arc_twitter_search tag – outputs results for specific keywords, hashtags, mentions, etc.
- Improved mentions and hashtag linking when updates are rendered
- The preference page will now properly update when the cache directory is changed
- v0.1.2
- Article tweet bug fixed – articles should now be able to be tweeted after publication
- Twitter account verification on the plugin preferences page
- Documentation corrected to include limit attribute for arc_twitter tag
Plugin details
Initial release: 28 November 2009
Current version: 0.2.2
[ download ]
Please feel free to leave your comments and questions about this plugin below. Alternatively you can post them on the forum thread.
Use of my plugins is free; however, if you would like to show your appreciation you can do so by clicking the 'Donate' button below and make a contribution to the Andy Carter's coding fund via PayPal...
Comment
Recent plugins
Textpattern links
Textpattern forums
Textpattern's support forums.
Textpattern Resources
A directory of plugins, tutorials, and other resources for and by the Textpattern community.
TXP Tips
Tips, tutorials, and code to help build better Textpattern websites.
We Love TXP
Design gallery of sites using Textpattern.
Nice Plug in! Like the fact you can tweet from the admin, do you have any future features planned? Things like – limit the amount of tweets shown? – Reply link
— Oliver Ker · Dec 4, 03:14 PM · #
Hi Oliver, glad you like the plugin. Slight mistake on my behalf when writing the documentation for the plugin; you can already limit the number of tweets shown using the limit attribute (up to a maximum of 200). I’m actually finding that at times Twitter is playing up and not returning the complete set of tweets, so the limit works more as a maximum than an actual number of tweets.
I have loads of new features planned. I’m currently working on some new public-side tags including one to make use of Twitter’s search methods. There are also plans to build upon the admin side of things. I’m taking suggestions and adding them to my list of things to do.
My overall aim is to make arc_twitter the complete Twitter solution for Textpattern.
— Andy · Dec 4, 08:45 PM · #
…oh, I notice that you are a fellow Yorkshireman! Nice website.
— Andy · Dec 4, 08:46 PM · #
Good stuff, what about the retweet button like wordpress for readers?
Didn’t realise ur were so close! My mrs is from your neck of the woods, they are all ‘Blades’.
Look forward to what else you come up with.
— Oliver Ker · Dec 6, 07:36 PM · #
Hi Andy, just wondering:
1. what type of url shortening your plugin uses? I am using Stef’s smd_short_url plugin on my site, which produces urls in the format: site.com/article_ID. I’d like to provide the links in this format if possible.
2. how the articles are truncated to Twitter’s 140 character limit? Is it possible to optionally instruct your plugin to accept the excerpt as the text (where the excerpt text is less than or equal to 140 characters, naturally)?
— speeke · Dec 15, 01:54 AM · #
Good day! Unfortunately arc_twitter plugin makes not correct URL for article if I change it’s URL in input. Is it possible to repair this bag? Thank you!
— Andrey · Dec 18, 06:04 PM · #
Great update, thanks.
— Oliver Ker · Jan 28, 09:10 AM · #
Love your arc_twitter plugin… It would be cool to have the ability to put the date on it’s own line if possible?
Also, I’m experiencing a blank screen on the live site not sure why? I have to turn the plugin off for a few mins. Any ideas?
Keep up the good work Andy.
— Craig Valadez · Jan 30, 09:48 PM · #
Hi Craig,
Glad you like arc_twitter; I’m enjoying developing it.
I’m somewhat of a XHTML markup minimalist and like to let users play with the styling as much as possible through the CSS. The dates should all be output in span elements that you could style to a new line in the CSS. Having said that I just checked the markup produced by the new arc_twitter_search tag and realised that I have forgotten to apply classes to the spans to distinguish between the date and user spans. I’ll make sure that gets covered in the next update.
As for the blank screen I have never seen that happen before. Is it preventing the page to render completely? If your site is in live mode could you temporarily switch it to test mode to see if any errors are being generated?
— Andy · Jan 31, 06:22 PM · #
Hi, is it possible to use this plugin for Identi.ca which has a Twitter compatible API?
— Aion · Feb 5, 06:43 PM · #
Hi Aion, I’m not familiar with Identi.ca (although it was briefly talked about in our office last week). I’ll take a look at the API documentation and see how similar it is to Twitter’s API. If it is simply a change in the base URL of the request then possibly it would be worth enabling arc_twitter to work with both services.
— Andy · Feb 8, 06:32 PM · #
Hey Andy
Is this easily explainable?
Loaded Plug-in
Inserted Twitter name and password.
then this:It come up when I click on the twitter tab or the plug-in preferences.
Fatal error: Uncaught exception ‘Exception’ with message ‘PHP extension cURL is not loaded.’ in [content removed]
— Les Smith · Feb 9, 11:46 PM · #
Hey Andy could you please delete the significant part of that message as i didn’t redact part of that message when asking for help.
— Les Smith · Feb 9, 11:51 PM · #
And I solved it by enabling curl on the PHP server, Andy please delete the first post or redact everything after the first error line.
Thanks
— Les Smith · Feb 10, 01:10 AM · #