SDK Sample app for external developers to install
The Hootsuite dashboard is a tool which allows you to manage all of your social media in one place.
A Hootsuite app uses the Hootsuite JavaScript SDK in order to extend the Hootsuite dashboard by adding custom integrations with other service and useful features for users. Hootsuite apps can either be free or monetized.
This Sample App currently only contains a sample plugin component (allows users to send things from Hootsuite streams to an app) and a sample stream component. The plugin listens for a 'sendtoapp'
event and opens a modal, populated with the data from the message it was activated on. The stream displays some sample messages and has buttons that activate SDK functions. Components in a Hootsuite app are largely seperate but it is possible to communicate between them.
The Sample App can be hosted locally, or on Heroku or some other hosting service. The backend is a very simple NodeJS/Express app but you can swap out the backend with anything as long as you meet a few requirements. These are listed below in the Using another hosting solution section.
- Setup Heroku.
- Clone this repository.
git clone https://github.com/HootsuiteApps/sdk-sample.git
- Create a Heroku app for this sample app.
- Configure Twitter (Optional):
heroku plugins:install heroku-config
to install heroku-config plugin- rename .env-example to .env
- open .env to fill in the fields with your Twitter keys and access tokens.
heroku config:push
to write the contents of .env to heroku config
git push heroku master
to push this app to Heroku. Heroku should detect that this app is a Node/Express app and run your index.js file- Once Heroku says that it's done use
heroku open
and add /modal to the URL it opened in your browser. If it comes up with a blank page that has a "Show JSON Payload" button then the web server is setup correctly.
- If you already have a Hootsuite developer account head over to your Hootsuite app directory management page and create an app, and inside that app create a plugin component.
- Edit the plugin component and enter the following into the fields: For the plugin component Service URL use your endpoint for plugin.html, if you used Heroku and Node this would be
https://<heroku-app-name-here>.herokuapp.com/plugin
. Also, check off the Default Install box. - If you'd like to install a stream example as well you should create another component, but this time make it a stream. Edit it again and this time enter
https://<heroku-app-name-here>.herokuapp.com/stream
as your Service URL. - Install your app by going to your Hootsuite dashboard and navigating to the app directory (puzzle piece at the bottom of the left sidebar). Your app should be under Developer, install it.
- Test it by going to your Hootsuite dashboard, clicking the elipsis on any post and hitting Send to . This should pop up a modal with some info about the post you sent to the app.
- Edit your app in My Apps
- Under "Authentication Type" select "Single Sign-On (SHA-512)"
- Create a shared secret (preferably by randomly generating it) and enter it into the "Shared Secret" field and hit save at the bottom of the page.
- Paste the Shared Secret into .env, run
heroku config:push
and you should be good to go!
- Access the Google Cloud Console and create a project.
- Go to
APIs and Service -> Credentials
and hit create credentials and create a client ID for a web app. Setup your Authorized Javascript origins with your Heroku domain. - Copy your OAuth 2 Client ID and paste it into
modal.html
andstream.html
where it saysYOUR-CLIENT-ID-HERE
. - Google Sign-in should now work seamlessly. If it doesn't work then ensure that your Authorized Javascript origins are set up correctly in the Google Cloud Console.
You can host your app on any service, but here are few things to keep in mind:
- You need to accept POST requests on your plugin and stream endpoints.
- You need to host the static CSS, Javascript, and icons somehow.
- Your endpoints need to have HTTPS.
- Use it to send a post to your own servers and manipulate/save it.
- Process the images from a post and use the attachFileToMessage SDK function to put the processed images into the compose box.
- Compose messages using the composeMessage SDK function based on the contents of a message that was sent to your plugin.