Predefined API Sample app for external developers to install
This sample app contains a Media Library app. The Media Library enables users with the new compose functionality to pull in images from external sources to use in their social media posts. Media Library apps integrate external media sources into the Media Library, usually using the APIs of cloud services to retrieve a user's media. This app integrates the Media Library with Dropbox using Dropbox's HRA(HTTP(Hypertext Transfer Protocol) REST(Representational State Transfer) API(Application Program Interface)).
The Sample App can be hosted locally, or on Heroku or some other hosting service. The backend is a NodeJS/Express app.
- Setup Heroku.
- Clone this repository.
- Create a Heroku app for this sample app.
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/v1/status
to the URL it opened in your browser. If you get a blank page that saysOK
then you've configured Heroku 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 media library component.
- Edit the media component and enter the following into the fields: For the media component Service URL use your endpoint's root Heroku domain.
https://<heroku-app-name-here>.herokuapp.com
. - Create a Dropbox app in Dropbox's My apps. Choose the
Dropbox API
,App folder
access, and give it a name. - Edit your Hootsuite app in Hootsuite's My Apps. Fill in the field's as following. Left is Dropbox and right is Hootsuite
- App key -> Client ID
- App secret -> Client secret
https://api.dropboxapi.com/oauth2/token
-> Token URLhttps://www.dropbox.com/oauth2/authorize
-> Authorization URL
- Hit Save and copy the redirect URI in Hootsuite to Dropbox's redirect URI section.
- Install your app by going to your Hootsuite dashboard and opening up the Composer (Beta) at the top right. Open the Media Library by pressing the button near the upload area and install your app in the dropdown where
Free Images
is the current selection. - Log into your Dropbox account in the popup (You may need to enable popups on that page).
- Next you will need to provide some media for the Media Library to display.
- Open your Dropbox that you used to login in the Media Library.
- There should be a folder called Apps and inside that a folder with the name of the Dropbox App you created. Place all of your media that you want the app to display in that folder. For pictures, JPG format should be used. Videos and GIFs are currently not supported.
- You will have to wait for Dropbox to add media_info to the file before it appears in the Hoostsuite content library, this can take some time.
Note: These steps should only be used for an app in development as your dev token will override the app's auth and use the account of the developer who generates the token.
- Create a Dropbox app in Dropbox's My apps. Choose the
Dropbox API
,App folder
access, and give it a name. - Generate a Dropbox
Generated access token
and save it. - Set it as the environment variable
DROPBOX_ACCESS_TOKEN
. In order to do this on Heroku use the commandheroku config:set DROPBOX_ACCESS_TOKEN=<access token here>
Before you can release a Media Library app for use with the Hootsuite platform, your app must pass a set of tests verifying
that it satisfies our API requirements. You can run these tests yourself using Runscope and the MediaLibraryAppVerificationTest.json
file included in this repo.
Read below for instructions on setting up the tests to work with Runscope.
In order to use Runscope to run these API tests, you will need a Runscope account. If you don't already have one, sign up for an account here. After you have an account, follow the steps below to add the tests to your account.
- Download
MediaLibraryAppVerificationTest.json
from this repo. - Login to Runscope and select the
Tests
tab in the top-left. - Click
Import Test
in the bottom left. - You will be taking to a page titled
Import Tests into Cheerful String
. On this page, selectRunscope API Tests
. Then, add theMediaLibraryAppVerificationTest.json
file that you downloaded previously. - Click
Import Tests
, and then go back to theTests
tab. You should see a new box labeledMedia Library App Verification Test
.
Next, you will have to customize the test to work with your app.
After you've imported the test suite into Runscope, you will need to change the settings to work with your app. Here are instructions for doing that:
- Select the
Tests
tab in the upper-left, then hover over theMedia Library App Verification Test
that you just imported. Click theEdit
button that will appear in the lower-left corner of the box. - Under the
Environment
header, click the arrow next toTest Settings
to expand it. TheInitial Variables
tab should already be selected. - Click
Add Initial Variable
. We will be adding four variables to the tests. All variable names are case sensitive. - The first variable is named
baseURL
. For the value, enter the URL that your app has exposed for API calls. - The second variable is named
supportedMediaTypes
. For the value, copy and paste in this array:['Image', 'AnimatedGif', 'Video', Folder']
. Then, delete the variables that your app does not support from that array. For example, if your app only searches for images and gifs, you would delete'Video'
and'Folder'
from the array, so that the value reads['Image', 'AnimatedGif']
. This step will prevent the test suite from running tests on functionality that you don't support. - The third variable is named
authToken
. For the value, enter a valid access token for your app. If your app does not support authentication, just enter a dummy value for this variable. (You need some value for this variable, even if your app does not support authentication, or otherwise the tests will break.) - The final variable is named
nextCursor
. It should always be set todefaultCursorValue
. (The tests will automatically change this variable as they run, but you don't need to do anything yourself.) - At this point, the tests are fully configured. Click
Save & Run
near the top of the page in order to run the tests against your app!
You can configure your app to receive webhooks so you can be notified about events, such as when a Hootsuite user installs or uninstalls your app.
Go to My Apps to configure your webhooks URL. For example, using this sample app deployed to Heroku, your webhooks URL would be https://.herokuapp.com/webhooks.