appnet.js

A library for interacting with app.net written in JavaScript. Exported
as both a jQuery and a Node.js module.

In jQuery, every method is invoked from the object found at
$.appnet. Using Node.js, that object is the sole export. See the
examples below.

Most function map one-to-one onto the HTTP endpoints of the app.net
API. The exceptions are a few utility functions at the top level for
setting and checking authorization tokens, and the all.* functions
which are a convenient way to get an entire stream.

Download

When using this package with jQuery, the current release can be found at:

Reference

Utility Functions

Sets the user and/or app tokens. Required for various calls as noted below.

deauthorize

( )

Clears all tokens.

isLogged

( )

Returns true if either a user or an app token has been previously provided.

isApp

( )

Return true if an app token was previously provided.

isUser

( )

Returns true if a user token was previously provided.

'all' endpoints

$.appnet.all provides some convenience functions for fetching the contents of an entire stream, automatically using pagination parameters to make multiple calls to the API when necessary.

Caution These functions will keep calling and not callback until the
entire stream is fetched. If the stream is big, this can be a long
wait. Only use these when you are confident that the stream can be
fetched with a few calls.

These functions all return a mock response envelope with a 'data'
field containing an array of the entire set of objects fetched. If
they fail part of the way through, your rejection method will be
called with the failed response object.

Method

Parameters

Method Used

getSubscriptions

( args )

channel.getUserSubscribed

getMessages

( channel_id, args )

message.getChannel

getUserPosts

( user_id, args )

post.getUser

getFollowing

( user_id, args )

user.getFollowing

getChannelList

( channel_ids, args )

channel.getList

getUserList

( user_ids, args )

user.getList

app.net endpoints

These endpoints all return the result of invoking $.ajax() which is a
jQuery promise. You are then free to attach your own callbacks to it
etc. Typically the response you receive will be a response envelope
with a 'data' field containing the results of your operation on
success and a 'meta' field with the response code and any other
information associated with your query.