In this post, we look at how we can programmatically create and manage Twitter campaigns from AEM assets UI.
The business use case
An organization creates assets using various tools like Photoshop and then syncs/uploads them into AEM. The organization wants a user friendly way to directly post these assets on its Twitter account, from AEM Assets, and manage the status of the posted tweets via likes and impressions of the tweet. This increases the reusability of the assets (hosted in AEM) on its website as well as Twitter account.
The technical implementation of the solution for this is divided into three parts:
1. Customize AEM Assets to provide a custom button that provides a dialog to enter status and relevant tags for the post to be submitted to Twitter.
2. Create a custom workflow that posts the asset on Twitter after approval by an author. This workflow will be auto-triggered on post submission (as done in step 1).
3. Create a custom scheduler that fetches the number of likes and impressions of all the AEM assets posted on Twitter and then saves the information in the asset metadata.
Create your Twitter app on theTwitter Developers site and make a note of your OAuth Settings that will be needed for authentication.
The following values will be required to authenticate connection to the Twitter API from AEM — consumerKey , consumerSecret, accessToken, accessTokenSecret