Level: Intermediate
Example: Message Sending Example
The Javascript API gives you, the developer, the opportunity to take full advantage of our REST APIs. Getting started and creating simple applications is easy, but let's go through something a little trickier to give you an idea of the things you can do with a little more work.
When we're finished, you'll have something which displays contacts for the logged in user, and provides functionality for sending messages to those connections.
You can download the code from example.html
First, you'll need to set up your application. We're going to include a form for the message sending (which will be hidden by jquery until it's opened), a div to show the connections, and the login button for authentication.
See the JSAPI Authentication Tutorial for more information.
The framework is loaded with the instruction to let the user stay logged in:
And the authentication handler goes on the login button:
Now, to get the user's connections to show up in the correct place.
See the JSAPI Connections Tutorial for more information.
Along with the connection display, we'll add the jquery code to generate the dialog, and a click handler for the images to pop up the dialog.
Finally, add the code to handle the message sending. See the JSAPI M Tutorial for more information.