Skip to content

Latest commit

 

History

History
191 lines (116 loc) · 10.4 KB

documentation.textile

File metadata and controls

191 lines (116 loc) · 10.4 KB

TXP Tweet (arc_twitter for Textpattern)

  1. Author
  2. Installation / Uninstallation
  3. The arc_twitter tag
  4. The arc_twitter_search tag
  5. The arc_twitter_retweet tag
  6. The arc_twitter_tweet_url tag
  7. The arc_twitter_tinyurl tag
  8. Caching
  9. Preferences
  10. Tweeting articles
  11. 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

Author

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.

Installation / Uninstallation

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.

The arc_twitter tag

Syntax

<txp:arc_twitter user="drmonkeyninja" />

Usage

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

Example usage

<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.

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
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

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.

The arc_twitter_retweet tag

Syntax

<txp:arc_twitter_retweet />

Usage

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

arc_twitter_tweet_url

Returns the URL of the Twitter status for an article.

Syntax

<txp:arc_twitter_tweet_url />

<txp:arc_twitter_tweet_url>Link text</txp:arc_twitter_tweet_url>

Usage

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

arc_twitter_tinyurl

Returns the shortened URL of the article used for the Twitter update.

Syntax

<txp:arc_twitter_tinyurl />

<txp:arc_twitter_tinyurl>Link text</txp:arc_twitter_tinyurl>

Usage

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

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) 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).

Preferences

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.

Tweeting articles

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 (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).