node package manager



A tiny Node.js module to share on social networks

Only have a few simple commands Create a new instance

saucisse = new Saucisse(myConfig)

Post a tweet

saucisse.tweet "This is a saucisse tweet", console.log

Post a facebook message

saucisse.fb "This is a saucisse facebook message", console.log


We need an oauth authentication library to authenticate on twitter API.

Oauth = require('oauth').OAuth
https = require 'https'

Let's do it

Our main module class Saucisse

class Saucisse
  constructor: (options = {}) ->
    @options = options

Configuration part

There's a lot of configuration happening there

To get an app access token for facebook, cf : Publishing with an access token

if options.twitter?
      throw new Error("Missing twitter key") if not options.twitter.consumer_key?
      throw new Error("Missing twitter secret") if not options.twitter.consumer_secret?
      throw new Error("Missing twitter token") if not options.twitter.access_token?
      throw new Error("Missing twitter token secret") if not options.twitter.access_token_secret?
      @twitterOauth = new Oauth(
    if options.facebook?
      throw new Error("Missing app access token") if not options.facebook.access_token?
      throw new Error("Missing facebook graph id") if not options.facebook.graph_id?

twitter methods

Send a tweet.

Just take the text of the tweet as a parameter

  tweet : (text, done) =>
    data = status : text
      ((err, resp) -> done(errJSON.parse(resp)))

fb methods

Send a facebook message.

on the graphid configured for this instance Just take the text as a parameter

  fb : (text, done) =>
    postData = "message=#{encodeURIComponent(text)}"
    postData += "&access_token=#{@options.facebook.access_token}"
    opts = 
      host   : ""
      port   : 443 
      path   : "/#{@options.facebook.graph_id}/feed"
      method : "POST"
        'Content-Type'   : 'application/x-www-form-urlencoded'
        'Content-Length' : postData.length
    req = https.request opts(res) ->
      res.setEncoding 'utf-8'
      res.on 'data'(chunk) ->
        done nullJSON.parse(chunk)
    req.write postData

Public methods

module.exports = Saucisse