typetalk-js
v0.2.0
Published
JavaScript library for Typetalk
Downloads
25
Maintainers
Readme
JavaScript client library for Typetalk
typetalk-js aims to provide a complete, asynchronous client library for the Typetalk API.
For API details and how to use promises, see the JavaScript Promises.
typetalk-js is an unofficial library.
Typetalk
Typetalk - http://www.typetalk.in
Typetalk: Team discussions and collaboration through instant messaging.
Typetalk brings fun and ease to team discussions through instant messaging on desktop and mobile devices.
Requirements
Support Promises
Browser
Use a polyfill script tag:
<script src="https://www.promisejs.org/polyfills/promise-5.0.0.min.js"></script>
The global variable Promise becomes available after the above script tag.
Installation
Node.js
npm install typetalk-js --save
Browser
bower install typetalk-js --save
or clone the repository or just copy the files typetalk.js
or typetalk.min.js
to your server.
and then include it in your pages with <script src="typetalk.min.js"></script>
Getting started
See also
Setup (Client Credentials as Grant Type)
var Typetalk = require('typetalk');
var typetalk = new Typetalk({
'client_id': 'YOUR_CLIENT_ID__CLIENT_CREDENTIALS',
'client_secret': 'YOUR_CLIENT_SECRET__CLIENT_CREDENTIALS',
'scope': 'topic.read,topic.post,topic.write,topic.delete,my'
});
Setup (Authorization Code as Grant Type)
var typetalk = new Typetalk({
'client_id': 'YOUR_CLIENT_ID__AUTHORIZATION_CODE',
'client_secret': 'YOUR_CLIENT_SECRET__AUTHORIZATION_CODE',
'redirect_uri': 'https://YOUR_APP_DOMAIN/provider_cb',
'scope': 'topic.read,topic.post,topic.write,topic.delete,my'
});
Get access token using client credentials
typetalk.getAccessTokenUsingClientCredentials().then(function(data) {
typetalk.accessToken = data.access_token;
typetalk.refreshToken = data.refresh_token;
}, function(err) {
console.error(err);
});
Get my profile
typetalk.getMyProfile().then(function(profile) {
console.log(profile);
});
Get my topics
typetalk.getMyTopics().then(function(topics) {
console.log(topics);
});
Post message
typetalk.postMessage(1657, {'message': '@shoito Hellow World!'}).then(function(message) {
console.log(message);
});
Sample App using typetalk-js library
See also
License
MIT License - http://opensource.org/licenses/MIT