/fanfou-sdk-node

Fanfou SDK for Node.js

Primary LanguageJavaScriptMIT LicenseMIT

fanfou-sdk-node

Fanfou SDK for Node.js

Install

$ npm i fanfou-sdk

Usage

const Fanfou = require('fanfou-sdk')

OAuth

const ff = new Fanfou({
  consumerKey: '',
  consumerSecret: '',
  oauthToken: '',
  oauthTokenSecret: ''
})

ff.get('/statuses/home_timeline', {format: 'html'})
  .then(res => console.log(res))
  .catch(res => console.log(err))

XAuth

const ff = new Fanfou({
  consumerKey: '',
  consumerSecret: '',
  username: '',
  password: ''
})

ff.xauth()
  .then(res => {
    console.log(res)
    ff.get('/statuses/public_timeline', {count: 10})
      .then(res => console.log(res))
      .catch(err => console.log(err))

    ff.get('/statuses/update', {status: 'Hi Fanfou'})
      .then(res => console.log(res))
      .catch(err => console.log(err))
  })
  .catch(err => console.log(err))

For more usages, see the example.

Options

  • consumerKey: The consumer key
  • consumerSecret: The consumer secret
  • oauthToken: The OAuth token
  • oauthTokenSecret: The OAuth token secret
  • username: The Fanfou username
  • password: The Fanfou password
  • protocol: Set the prototol, default is http:
  • fakeHttps: A hook to replace the OAuth basestring, default is false
  • apiDomain: Set the API domain, default is api.fanfou.com
  • oauthDomain: Set the OAuth domain, default is fanfou.com

For more Fanfou API docs, see the Fanfou API doc.

API

ff.xauth()
ff.get(uri, params)
ff.post(uri, params)
ff.upload(uri, params)

Examples

ff.get('/statuses/home_timeline', {})
  .then(res => console.log(res))
  .catch(err => console.log(err))

ff.post('/statuses/update', {status: 'post test'})
  .then(res => console.log(res))
  .catch(err => console.log(err))

ff.upload('/photos/upload', {photo: fs.createReadStream(path), status: 'unicorn'})
  .then(res => console.log(res))
  .catch(err => console.log(err))

Related

License

MIT © LitoMore