fanfou-sdk-node
Fanfou SDK for Node.js
Install
npm i fanfou-sdk
Usage
import Fanfou from 'fanfou-sdk';
OAuth
const ff = new Fanfou({
consumerKey: '',
consumerSecret: '',
oauthToken: '',
oauthTokenSecret: ''
});
const timeline = await ff.getHomeTimeline();
XAuth
const ff = new Fanfou({
consumerKey: '',
consumerSecret: '',
username: '',
password: ''
});
await ff.xauth();
const timeline = await ff.getPublicTimeline({count: 10});
const status = await ff.createStatus({status: 'Hi Fanfou'});
Options
consumerKey
: The consumer keyconsumerSecret
: The consumer secretoauthToken
: The OAuth tokenoauthTokenSecret
: The OAuth token secretusername
: The Fanfou usernamepassword
: The Fanfou passwordprotocol
: Set the prototol, default is http:
apiDomain
: Set the API domain, default is api.fanfou.com
oauthDomain
: Set the OAuth domain, default is fanfou.com
hooks
: Hooks allow modifications with OAuth
For more Fanfou API docs, see the Fanfou API doc.
API
For full SDK API, please refer to the documentation.
Examples
const token = await ff.getRequestToken();
const token = await ff.getAccessToken(token);
const timeline = await ff.getHomeTimeline();
const status = await ff.createStatus({status: 'post test'});
const result = await ff.uploadPhoto({photo: fs.createReadStream(path), status: 'unicorn'});
const user = await ff.getUser({id: 'lito'});
const timeline = await ff.get('/statuses/home_timeline', {count: 10});
const status = await ff.post('/statuses/update', {status: 'Hi Fanfou'});
Tips
Use hooks
for your reverse-proxy server
const ff = new Fanfou({
consumerKey: '',
consumerSecret: '',
oauthToken: '',
oauthTokenSecret: '',
apiDomain: 'api.example.com',
oauthDomain: 'example.com',
hooks: {
baseString: str => {
return str.replace('example.com', 'fanfou.com');
}
}
});
Related
License
MIT