The publication to Twitter is implemented via code WF rather than through an external DLL. This allows quicker changes and customizations if these are necessary.
This topic describes the Publishing to Twitter function, with its configuration. It is desirable that this workflow will become the standard in the distribution and the old one removed from GN4 1.6 onwards.
Twitterizer has been replaced with a new .NET assembly, LinqToTwitter, available here: http://linqtotwitter.codeplex.com/
Installation
Download the latest version of LinqToTwitter from http://linqtotwitter.codeplex.com/
Extract the file LinqToTwitter.dll from the folder Net40 of the ZIP. For GN4 2.0 - using .Net 4.5 - get the version in the net45 folder. DO NOT USE THE "CLIENT" VERSION OF THE DLL!
1.Copy the DLL in the BINARY folders (c:\tera\gn4\bin and c:\tera\gn4\web\portal\bin, usually)
2.Load in GN4 the workflow wf_TwitterPublishing.xml:
cmd4 config -in wf_TwitterPublishing.xml
3.Load in GN4 the Twitter publishing template TwitterTemplate.xml:
cmd4 import -in TwitterTemplate.xml
4.Load the xsl_ToTwitter.xsl style sheet after having adapted it to your schema!
cmd4 config -in xsl_ToTwitter.xsl
You can download the XML files at the bottom of this post
Configuration
The TwitterPublishing workflow does all the logic of the publication to Twitter and it is called by the "Twitter" template's Publishing workflow. The publishing templates requires four authentication strings to log into Twitter. The idea behind this is that we generally associate a single Twitter account to a newspaper (@TheDailyBugle) and "tweet" on the newspaper's behalf. But we could also create Publishing Destinations that tweet on a user's behalf (@JohnDoe): only the relevant user will see the destination thanks to his/her permissions.
We need to generate these codes for each different account. This is a one-time operation to be carried out by the customer
1.Sign in to http://dev.twitter.com/ with the Twitter's username and password of the account to send tweets from GN4
2.Select "My Applications" from the user account:
3.Click the button "Create new Application".
4.Fill in the form as per image below (of course, enter whatever strings are necessary):
5.Agree to the Terms and conditions and fill in the captcha: the application will be created (please note that the name "GN4" is already in use: it is recommended that the application name contains the customer's name). A screen like the below should appear:
6.The application must be set to be able to write to Twitter: click the tab "Settings" and in "Application Type", select "Read/Write":
7.Then, save the changes by clicking the "Update" button at the end of the page.
8.Return to the "Details" tab and click the "Create Access Token" button at the bottom of the page.
9.If you now click on the "OAuth tool" tab, you will see all four tokens necessary to publish tweets from GN4:
10.Sign in in GN4's "Int" interface and create a new Publishing Destination using the "Twitter" template.
11.Fill in the relevant access permissions with the tokens from Twitter: the names should be self-explicative:
Parameters
In addition to the four authentication strings from Twitter, the Publishing Template receives another parameter, gnwebUrl which is the base URL of the GNWeb version of the article. The publication template uses a Style Sheet (xsl_ToTwitter) to compute the URL. If the parameter gnwebUrl is present, the URL of the story will be appended to the post. With version 1.1 of the Twitter API, Twitter itself will shorten the URL by providing a link to its service (t.co). For further information: https://support.twitter.com/entries/109623#
The publishing workflow will compute the parameter TwitterTxt to be passed to the TwitterPublish workflow. This string will be truncated, if necessary, before posting it to Twitter.
Known issues
For the moment, no provision to un-tweet a story has been implemented. To do so, we should save the ID of the tweet against the published object, then call the LinqToTwitter function DestroyStatus (https://linqtotwitter.codeplex.com/wikipage?title=Destroying%20Statuses). This would require a schema change: I propose the default schema is changed so that there is an attribute against the published information to keep the ID from a system where we have published the object. It will then be simple to implement the function to un-tweet a story.
Twitter doesn't allow the "update" of a tweet, which may cause problems if we re-publish the same story in a short time from the first tweet. If we want to allow users to update (?) a tweet, we will have to first destroy the tweet then create a new one.
We had requests from users on who to allow to tweet, whether a single account for the publication (@TheDailyBugle) or individual users. I think that the main "Twitter" should be the newspaper, but we should allow users to retweet tweets. This can be done but, as there may be different options, it is perhaps better if we have a discussion on what options to allow. For the moment, I see the following possibilities:
1.Only a single Tweeter: the publication (as currently implemented)
2.The publication does the tweet and the journalist who initiated the tweet in GN4, re-tweets it
3.The journalist does the tweet and the publication re-tweets it
4.A separate tweet of the same story is done by the publication and the journalist
5....