inspiredminds/contao-news-twitter
Project web site: Contao News Twitter Sync
This extension allows to automatically import Twitter tweets as news entries. It also enables you to automatically post news entries on a Twitter profile as a tweet. This allows you to keep a Twitter profile in sync with a news archive.
To install this extension, the composer.json
of your Contao installation has to
be modified first. Two adjustments have to be done: adding the private repository
& adding the dependency.
To add the repository, add the following to your composer.json
:
{
"repositories": [
{
"type": "composer",
"url": "https://token:<YOUR_TOKEN>@packdis.inspiredminds.at/r"
}
]
}
Replace <YOUR_TOKEN>
with the repository token you received from inspiredminds.
To add the dependency, add the following to your composer.json
:
{
"require": {
"inspiredminds/contao-news-twitter": "^2.0"
}
}
After making this adjustment, run a composer update
on the command line or update
your packages via the Contao Manager. Then open the Contao Install Tool to update the database as usual.
To configure this extension, a “Twitter App” needs to created first. The details of this app are then needed for the configuration in the back end.
https://www.example.org/contao
.In Contao, go to System » Settings, scroll down to the Twitter App section, enter the Consumer Key and Consumer Secret. You can find both in the settings of your Twitter App under Keys and tokens.
Go to the settings of your news archive. In the Twitter sync section enable Twitter sync. Now you have the following options:
Authentication: by clicking on the profile picture (or question mark), you can (re-)authenticate with your Twitter account. This is necessary if you want to tweet your news entries to your profile automatically. It is not necessary to authenticate, if you only want to fetch tweets from hashtags or Twitter profiles.
Profile: the Twitter profile where tweets should either be fetched from or posted to.
Hasthtags: space or comma separated list of hashtags that should be fetched from Twitter. Note: if you have also defined a Profile this lists acts as a filter for that Profile only. Without a Profile any public tweets with that hashtag will be fetched.
Fetch tweets: tweets will only be fetched from the given profile (or globally from the hashtags) if this options is active.
Publish tweets: any tweets that are fetched as news entries will be automatically be set to published.
Once you have configured the news archive and also enabled the Fetch tweets option the extension will check for new Tweets hourly via Contao’s cronjob.
Contao news entries will be published as tweets under two conditions:
You can also define a custom message for the tweet. If no such message is defined, the news entry’s headline is used by default.
If the news entry has a teaser image, that image will also be attached to the tweet.
The extension will check for new news entries to be published minutely via Contao’s cronjob.
There is a link in the news archive overview to manually trigger the synchronisation.
processTweet
The extension processes a tweet and tries to convert it to a fitting Contao news
entry as best as it can. If you want to customize the final data for a news entry
of a tweet, you can use the processTweet
hook. It expects an array containing
the final news entry data as the return value. If the return value equals to false,
no news entry will be created.
$arrData
The already processed data which will be used for the new
news entry.$objTweet
The original tweet data.$objArchive
The news archive object.changeTwitterMessage
When posting a Contao news entry as a tweet, the extension either uses the teaser
or the specified message of the news entry. If you want to automatically provide
a different message, you can use the changeTwitterMessage
hook. It expects the final message as the return value.
$message
The already prepared message.$objArticle
The original Contao news entry.$objArchive
The news archive object.There is additional data available in the news templates:
twitterData
The original tweet datatweetId
The tweet ID of the linked tweetfromTwitter
Indicates whether this news entry was fetched from Twitter