- Author
- Installation / Uninstallation
- The arc_twitter tag
- The arc_twitter_search tag
- The arc_twitter_retweet tag
- The arc_twitter_tweet_url tag
- The arc_twitter_tinyurl tag
- Caching
- Preferences
- Tweeting articles
- The Twitter tab
TXP Tweet 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
Andy Carter. For other Textpattern plugins by me visit my Plugins page.
If you like this plugin and want to see development work continue you could consider sending me a small incentive using the Donate button on the Plugins page of my site.
Thanks to Michael Manfre for inspiration for the article tweet part of this plugin based on his mem_twitter plugin. Additional thanks to the great Textpattern community for helping to test this plugin and for suggesting new features. The OAuth part of the plugin is thanks to Abraham Williams.
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 associate your site with a Twitter account by connecting to Twitter from the plugin’s options screen. Click on the link to connect to Twitter, you will be asked to login to Twitter, clicking this link will temporarily take you to the Twitter site where you will be asked to login and approve access for TXP Tweet to read and write to your Twitter account. If all is successful you will be returned to the options screen and your user name will appear.
At any time you can disassociate your Twitter account with TXP Tweet via your Twitter account preferences on the Twitter website.
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.
<txp:arc_twitter user="drmonkeyninja" />
Attribute | Description | Default | Example |
---|---|---|---|
user | Twitter user name | arc_twitter username | user="drmonkeyninja" |
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" |
class_posted | CSS class attribute applied to span tag around posted date | arc_twitter-posted |
<txp:arc_twitter user="drmonkeyninja" limit="5" wraptag="ul" break="li" dateformat="%b %Oe, %I:%M %p" />
Produces a bullet point list of the last 5 Twitter updates from drmonkeyninja’s Twitter feed with a defined date format to override the default archive date format.
<txp:arc_twitter_search hashtags="txp" />
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 | |
class_user | CSS class attribute applied to span tag around user name | arc_twitter-user | |
class_posted | CSS class attribute applied to span tag around posted date | arc_twitter-posted |
<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.
<txp:arc_twitter_retweet />
Attribute | Description | Default | Example |
---|---|---|---|
user | Twitter user name to quote | arc_twitter username | user="drmonkeyninja" |
url | URL to retweet | ||
text | Retweet text | ||
follow1 | Suggested Twitter account to follow, for example your own | A Twitter user to recommend | follow1="Textpattern" |
follow2 | As follow1 | unset | |
lang | Language | en | lang="es" |
count | Count box position, options: none, horizontal or vertical | horizontal | count="none" |
include_js | Whether or not to include the JavaScript | 1 | include_js="0" |
wraptag | HTML tag to be used as the wraptag, without brackets | unset | |
class | CSS class attribute applied to the retweet button | twitter-share-button |
Returns the URL of the Twitter status for an article.
<txp:arc_twitter_tweet_url />
<txp:arc_twitter_tweet_url>Link text</txp:arc_twitter_tweet_url>
Attribute | Description | Default | Example |
---|---|---|---|
id | Textpattern article ID | current article | id="1" |
title | Title attribute of the link | unset | |
class | CSS class attribute applied to the link | unset |
Returns the shortened URL of the article used for the Twitter update.
<txp:arc_twitter_tinyurl />
<txp:arc_twitter_tinyurl>Link text</txp:arc_twitter_tinyurl>
Attribute | Description | Default | Example |
---|---|---|---|
id | Textpattern article ID | current article | id="1" |
title | Title attribute of the link | unset | |
class | CSS class attribute applied to the link | unset |
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) | arc_twitter preferences | |
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).
You can access the plugins core preferences from either the Preferences or Plugins tabs in admin. Setup your Twitter account (you will be asked to connect via Twitter and this needs doing before you can use the plugin) 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.
You can select the URL shortener method you want to use to link back to your article on Twitter. Please note that if you select smd_short_url you will need to have installed and activated the smd_short_url plugin developed by Stef Dawson.
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.
Under the Extensions tab (this can be changed from the plugin’s preference page) a new Twitter tab should appear once you have connected your site to your Twitter account. 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).