writings from zac anger, who is not all that angry

kik's api

February 17, 2016 — Zac Anger

Kik's API is kinda basically shit. Their API docs are also basically shit. Probably becaues their API is basically shit. Kik's a lot more focused on people building Kik-friendly websites than they are on people integrating with their service.

Kik's js:

Kik requires that we make terms of use and privacy policy available, like so:

User-related stuff:

  } else {
    // user.fullName
    // user.firstName
    // user.lastName
    // user.pic
    // user.thumbnail
    // ^^ these are all strings.
  // cool! user has given us permission to work with their account
// to work with a user anonymously (doesn't expose identifying
// information, also doesn't require permission from user):
  console.log(token) // str
// kik's auth only works over https.
kik.sign('foo bar data etc.', function(signedData, username, host){
    // either failed, or user denied
  } else {
    console.log(signedData, username, host)
    // all strings. need to be passed to verification service.
    // we'd pass stuff to a back-end for that.
// to make this work with the anonymous thing, it's almost exactly the same:
kik.anonymousSign('data', function(signedData, anonToken, host)){
  // same stuff, except we would get anonToken instead of username


  title     : 'message title'
, text      : 'message content'
, pic       : 'http://if.we/want/to/send/a/photo'
, big       : true // optional, for large images, etc.
, noForward : true // optional, for restricting receiving user from forwarding the message
, data      : {something: 'stuff'} // optional, arbitrary JSON, max 7.5kb
kik.send('otherUser', {
  title : 'etc'
// all the same stuff here.
  // do things; now we know the user has opened the message.

Kik has some analytics stuff for messaging, but I really just don't care about that.

Social things:

kik.showProfile('zacanger') // shows profile!
  if(!users) // cancelled, maybe.
}  else {
    alert('user.username') // etc., all the same stuff from the user info.
kik.pickUsers({minResults:1,maxResults:4}, function(users){
// etc.
kik.pickUsers({preselected:[{username:'zacanger'}]}, function(users){
// same objects as from call to pickUsers
kik.pickUsers({filtered:['badPerson','iHateThisGuy']}, function(users){
// users we don't want to show. doesn't work with preselected.
kik.pickUsers({filterSelf:false}, function(users){
// allow user to see their own profile in the user picker


// events:
function someEventHandler(){
// do stuff...?
kik.on('event', eventHandler) // bind to event // unbind
kik.once() // only bind once, ignore after that.
// event can be, for example, 'message'.
kik.trigger('message', {title:'title'}) // objects are passed to all even listeners.

// platform & browser detection:
var platform = kik.utils.platform.os
console.log(, os.version) // string, int
var browser = kik.utils.platform.browser
console.log(, browser.version)
var eng = kik.utils.platform.engine // rendering engine
console.log(, engine.version)
// for unsupported browsers (iOS <= 5, android <= 2.3), use a meta tag:
// <meta name="kik-unsupported" content="android-2.3"> (or whatever).

tags: kik, api

so, tweet it?  


January 15, 2016 — Zac Anger

Pusher is a hosted API for WebSockets, with Flash and HTTP fallbacks (in the JS lib). They also have a REST API. It's a simple pub/sub model, with filtering and auth, which allows for private channels and presence functionality. Getting up and moving in JS is pretty simple: include pusher.js (<script src="//"></script>), open a connection with var pusher = new Pusher('API-KEY), subscribe with var channel = pusher.subscribe('channel-name'). Listening for events:

channel.bind('event-to-listen-for', function(data){  
  console.log('event was triggered... message: ' + data.message)  

Using their server lib (for Node):

var Pusher = require('pusher')  

var pusher = new Pusher({  
  appId: 'APP-ID'  
, key: 'APP-KEY'  
, secret: 'APP-SECRET'  

pusher.trigger('channel-name', 'event-to-listen-for', {'message': 'boing!'})  

tags: pusher, realtime, api, baas, paas

so, tweet it?  

zac anger?