On your web server
Your sample app will require the following files hosted within your domain's root directory:
At hootsuite.com
To create a stream for your app in My Apps:
You have now created a stream for your app.
On your web server
In order to enable your app's ability to send and receive messages to and from the HootSuite dashboard, you will need to add a reference to the HootSuite hosted portion of the App Directory SDK. This file is located here:
http://static.hootsuite.com/jsapi/0-5/hsp.js
To reference this script, add the following HTML snippet to the top of the <body> section of your my_app.html file:
In order to receive events from the HootSuite dashboard, your my_receiver.html will need to reference your locally downloaded copy of app_receiver.js. To accomplish this, add the following HTML snippet to the top of the <body> section of your my_receiver.html file:
Where <YOUR DOMAIN> is your local domain (ex. localhost).
You have now set up the communication channels for your app to send and receive messages to and from the HootSuite dashboard. Next, you will add the code to actually use this communication layer.
In my_app.html, initialize the JS API using the hsp.init function and set the hsp parameters:
apiKey string use the API Key retrieved in the
Create an App
section, Step 4.receiverPath string use the absolute URL of my_receiver.html (ex. http://localhost/my_receiver.html).
Insert this code in between HTML script tags, in the <body> section of the file:
Where <MY API KEY> is the retrieved API Key and <YOUR DOMAIN> is your local domain.
Add some content to your app. In the my_app.html file, at the top of the <body> section of the document, insert the following HTML:
At hootsuite.com
Inside your HootSuite dashboard:
At this point you should see your app appear in a HootSuite stream with the heading that you added in Step 6. It should look similar to this:
On your web server
Let's add functionality that will make your app communicate with the HootSuite dashboard. We'll do this by using two basic functions available in hsp.js:
hsp.showTrends(): Shows latest trending topics.hsp.showUser(twitterHandle): Opens a user info popup for the specified twitter username. Let's use HootSuite (@hootsuite) as an example.The code should be placed in the <body> section of my_app.html, right after the heading added in Step 6. It should look something like this (line break tags are optional):
Let's check if your app is enabled to receive events from the HootSuite dashboard by using the hsp.bind() function for two different types of events:
refresh: Fired when the app stream is refreshed.dropUser: Fired when a user drags and drops a Twitter account from the HootSuite dashboard into your app stream.
We will place this functions in my_app.html, in between the script tags used for hsp.init(), right after such function created in Step 5.
Where window.location.reload() reloads the app streams' window and dropping a Twitter account into the app stream will use the hsp.showUser(twitterHandle) function described in Step 8.
In part 1 “Google+ for Brands: 4 Reasons your Brand Should Be on it”, we...
Read More
This week, inspiring women were all over the US Twitter trends. From Angelina Jolie motivating...
Read More
This week’s global Twitter trends combine the heavy with the light-hearted. Mixed in with Mother’s...
Read More
What’s more beautiful than twenty pictures of children smiling and being creative? Enjoy this Friday...
Read More