About PublishToTwitter3

Offers an option to publish a page to Twitter when the date for publishing is past/scheduled.

Category Social, Feeds, Services
Modules that provide or work with social networking services and/or external feeds.
Release StateStable
Should be safe for use in production environments. *
Authorferdiagrio
Module Version1.0.0
Class NamePublishToTwitter
Compatibility3.0
Date AddedMarch 25, 2016
Last UpdatedFebruary 21, 2017
Recommended ByNew recommendations may take up to 1 day to appear.

Details

A module to send Tweets when selected at the page editor. When using PW v2.x you should use PublishToTwitter2.

In short this module offers an option to publish a page to Twitter when the date for publishing is past/scheduled. Optional add the website name and/or image(s) of the page.

Uses (included) TwitterOAuth PHP library written by abraham.

Update 0.8.6: optional use of prepend text, find out which account is connected when submitting module-settings.
Update 0.8.7: supports FieldtypeCroppableImage3
Update 0.8.8: validation for correct template/parent/status (PW 2.x)
Update 0.8.9: validation for correct template/parent/status (PW 3.x)
Update 1.0.0: bugfix prevent htmlentities when using cron

Changed the title of the module to PublishToTwitter2 and PublishToTwitter3 to prevent mistakes.

GitHub PublishToTwitter3 (ProcessWire 3.x)
GitHub PublishToTwitter2 (ProcessWire 2.x)

Instructions

Download the module in ZIP format and upload it in your site/modules/ folder or type/paste "PublishToTwitter" in the field where you can download and install new modules at your site.

Fill out the required Twitter credentials (Twitter Consumer Key, Twitter Consumer Secret, Access Token and Access Token Secret) which can be found/created at https://apps.twitter.com.
Next it is required to select at least one template which should have the option added to Tweet the pages using it.
Additional it is required to select the field to use as publication date to check if the Tweet should be send now or later. The latest required option is the field which contains the page title.

  • Optional you could add suffix text (for example the name of the website) which will be added after the content of the selected Page title field. This is only the case as long there are enough remaining characters available, at the moment Twitter allows a total of 140 characters.
  • Optional you can select an image field. When there are images available, only the first image will be attached to the Tweet. Images will be automatically down scaled to serve the Twitter recommended image size.
  • Optional you can fill out Bit.ly credentials (Login, Access Token) for shortening URLs (at a more elegant way Twitter does for you).

Also included are instructions to set a cron-task (using a custom page/template or with use of the LazyCron module) and a logging file (PublishToTwitterCron.txt) in the assets folder which will only be used when the cron-task is triggered (function RunCronPublishToTwitter()).

README

PublishToTwitter

Processwire 3.x module to Tweet pages

In short this module offers an option to publish a page to Twitter when the date for publishing is past/scheduled.

After filling out the Twitter credentials, select your preferable template(s) which should have the option added to Tweet the pages using it. Additional select the field to use as publicationdate to check if the Tweet should be send now or later, a field which contains the page title.

Optional you can fill out the name of the website which will be added after the title (in case space is available).

Optional you can select the field where the page image(s) are placed (only one will be tweeted).

Optional use of Bit.ly (needs credentials) to shorten the URL length in a more elegant way Twitter does.

Includes instructions to set a cron (template or LazyCron), returns log in assets folder.

Uses (included) TwitterOAuth PHP library (https://github.com/abraham/twitteroauth) written by [abraham](https://github.com/abraham).

To use the module combined with a cron, the following code can be used in a template.

// when using LazyCron

if ($this->cronInterval) {$this->addHook("LazyCron::{$this->cronInterval}", null, 'RunCronPublishToTwitter'); } else { if (date('G') > 7 && date('G') < 23) { $this->addHook('LazyCron::every5Minutes', null, 'RunCronPublishToTwitter'); } else { $this->addHook('LazyCron::every6Hours', null, 'RunCronPublishToTwitter'); } }

// OR - for use in manual cron

$ptt = wire("modules")->get("PublishToTwitter");$ptt->RunCronPublishToTwitter();

Check out the Processwire modules section for more details.

Comments

  • Hugo Morales

    Hugo Morales 7 months ago 00

    Hi Ferdi, Good work, great stuff, Thanks.

    About ProcessWire 2.x, where do I get the 0.8.2 version ?

  • Ferdi

    Ferdi 7 months ago 00

    I've split the master branch in GitHub > https://github.com/FerdiAgrio/PublishToTwitter/tree/PW-version-2x

Post a Comment

Your e-mail is kept confidential and not included with your comment. Website is optional.