Current version: 0-5
JSApi is the App Directory SDK's communication gateway between your app and the HootSuite dashboard. The API allows app developers to call functions that send events to the HootSuite dashboard and to receive event notifications specific HootSuite dashboard events of within an app.
Interactions between HootSuite and your app are enabled by two files:
The following files are needed to use the JS API:
http://static.hootsuite.com/jsapi/0-5/hsp.js
For example, the reference to this file in your primary page would appear as follows:
http://static.hootsuite.com/jsapi/0-5/my_receiver.html
Note: If you need HTTPS, use https://d2l6uygi1pgnys.cloudfront.net instead of http://static.hootsuite.com
Communication from your app to the HootSuite dashboard occurs using the functions available in hsp.js.
Communication from the HootSuite dashboard to your app is enabled through events. The events that your app is interested being notified about are registered with calls to the hsp.bind() function indicating the event of interest and the callback function that your app will execute when the event it triggered.
Functions
Events
Initializes the JS API and loads the theme CSS files.
params: object:
Registers an event handler for a specified event.
Note: This requires the App Receiver to be set up.
eventName: (string)
Name of the event to handle, can be one of the following:
callback: (function)
Function to handle the callback, the function's parameters are determined by the event. See the events section for details on expected callback formats.
Example:As stated in the Best Practices section, it makes sense to suppress reloading of the stream while the user interacts with it (e.g. posting messages, expanded details, possibly scroll position not near the top). A possible approach could look something like this:
The use of window.location.reload() is obviously not the best approach and was used mostly for simplicity of the examples. One of the most elegant solutions would be to poll for any new messages via AJAX and to inject only new messages into the DOM while leaving existing messages untouched.
Removes all currently visible status messages.
Opens the Share to Social Networks dialog in the HootSuite dashboard.
message: (string)
Twitter message rules apply, eg. to compose a DM to @HootSuite would be: d hootsuite <your message here>
params: (object, optional):
Shows a modal popup window containing an iFrame showing content from the specified URL. On close the dialog fires the closePopUp() event.
src (string)
URL of the content to show in the popup
title (string)
The title displayed on the popup window
width (int)
The width in pixels of the popup. The width has the following constraints:
height (int)
The height in pixels of the popup. The width has the following constraints:
Please do not initialize hsp again inside the custom popup. Your popup is not supposed to use any hsp functions other than closeCustomPopup(apiKey, pid).
If your popup and app stream/plugin are in the same domain, it is recommended that your popup uses the following javascript function to communicate back to your stream/plugin and run the hsp function: window.parent.frames[apiKey_pid].hsp.some_function().
Note: hsp event binding functions are not available in the custom popup.
Closes the modal popup window. Note: Please make sure the iFrame page in the custom popup window and the app stream page are sharing the same domain. You don't need to (and shouldn't) call hsp.init() again in the iFrame page, just include hsp.js and call hsp.closeCustomPopup(apiKey, pid). You can use JavaScript to communicate between the popup and the stream like this:
apiKey (string)
Your app's API Key
pid (string)
The pid is associated with each unique installation of an app stream (or plugin). You can get the pid of each app stream from the url request your server gets. For example:
http://demo.ca/stream.html?lang=en&theme=blue_steel&timezone=-25200&pid=60956&uid=136
Shows an image in a popup window, optionally linking to an external URL.
src (string)
Image URL
externalURL (string)
URL to open if user clicks on the image
Shows a notification in the top center of the HootSuite dashboard.
message (string)
Should be brief, max. 70 characters.
type (string):
Can be one of the following:
Updates the subtitle of the App's stream.
Note: This requires the App Receiver to be set up (see above).
name (str)
Max 35 characters
Opens a user info popup for the specified Twitter username.
twitterHandle (string)
Twitter username
Example:
Opens a dialog window for following or un-following a Twitter user.
twitterHandle (string)
Twitter username
isFollow (bool)
true to follow, false to unfollow.
Example:
Gets a list (array) of all Twitter profiles (user names) the logged-in user has added to their HootSuite account.
callback (function)
Function that accepts an array strings
Example:Assign a message, or any text content, to a HootSuite user (self, or team member)
data (JSON object)
Example:This section describes the set of available events and expected event handler function signatures available by using hsp.bind().
Fires when the app column is refreshed, either by the user within the stream, or as part of a dashboard refresh.
callback format- a function with no parameters
Example:Fires when a user drags & drops a Twitter user avatar from the HootSuite dashboard into your app stream
callback format- a function with two parameters, the Twitter handle of the user and the unique ID of the Tweet from which the user was dragged
Example:Adds app plugin to the native HootSuite social network selector. User can send messages to the plugin directly from HootSuite compose message box
NOTE: You need to contact our app directory administration team to enable this event binding for your app plugin
callback format- a javascript object containing the message data
Message object data structure: Example:Fires when a custom popup opened by your app stream is closed
callback format- a function with no parameters
Example:Registering for this event will cause users to see a menu item reading Send to <app stream>...in Twitter and Facebook stream message menus. This event is fired when users click on the menu item.
callback format- a javascript object containing the message data
Message object data structure: Example message object: Example:Registering for this event will cause users to see a menu item in Twitter, Facebook, LinkedIn and Google+ Page profile menus. The event is fired when users click on the menu item.
callback format- a javascript object containing the profile data
Profile object data structure:(click on the link to expand)
TwitterRegistering this event will let an app get notified of its assignment updates
callback format- a javascript object containing the update information data
Sample Assign To Callback: Sample Resolve Callback:These functions are part of the OAuth authentication procedure, as described on the "Authentication process" page.
Initiates the Session Token creation process.
When this is called, HootSuite sends the stored OAuth Access Token to the App's Authentication Endpoint which validates the token, and creates and returns a Session Token. HootSuite then reloads the App stream, passing the new Session Token token as a URL parameter.
Displays the authentication popup for the app.
Rich media content has become king. And as quality imagery and video pick up marketing...
Read More
8,848 metres. 29,029 feet. What do these numbers represent? Both the height of Mount Everest,...
Read More
It’s the worst nightmare of many C-suite executives. Someone has control of your social media...
Read More
A growing number of governments, from municipal to federal, are increasing their engagement through social...
Read More