# fanfou-sdk-browser

> Fanfou SDK for browser

Latest version **0.8.0** (published 2020-05-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install fanfou-sdk-browser
pnpm add fanfou-sdk-browser
yarn add fanfou-sdk-browser
bun add fanfou-sdk-browser
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.8.0 |
| Published | 2020-05-18 |
| First published | 2018-10-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 5 |
| Unpacked size | 22.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | LitoMore |
| Maintainers | litomore |

## Links

- npm: https://www.npmjs.com/package/fanfou-sdk-browser
- Repository: https://github.com/fanfoujs/fanfou-sdk-browser
- Homepage: https://github.com/fanfoujs/fanfou-sdk-browser#readme
- Issues: https://github.com/fanfoujs/fanfou-sdk-browser/issues
- npm.io page: https://npm.io/package/fanfou-sdk-browser

## Dependencies (5)

- [he](https://npm.io/package/he.md) ^1.2.0
- [ky](https://npm.io/package/ky.md) ^0.19.0
- [hmacsha1](https://npm.io/package/hmacsha1.md) ^1.0.0
- [oauth-1.0a](https://npm.io/package/oauth-1.0a.md) ^2.2.6
- [query-string](https://npm.io/package/query-string.md) ^6.8.3

## Recent versions

- 0.8.0 (latest) — 2020-05-18
- 0.7.0 — 2020-03-25
- 0.6.0 — 2020-02-23
- 0.5.0 — 2020-02-23
- 0.4.0 — 2019-06-04
- 0.3.3 — 2019-05-21
- 0.3.2 — 2019-01-30
- 0.3.1 — 2019-01-25
- 0.3.0 — 2018-11-18
- 0.2.0 — 2018-11-15
- 0.1.2 — 2018-11-12
- 0.1.1 — 2018-10-30
- 0.1.0 — 2018-10-05

## README

# fanfou-sdk-browser

[![](https://github.com/fanfoujs/fanfou-sdk-browser/workflows/Node/badge.svg)](https://github.com/fanfoujs/fanfou-sdk-browser/actions)
[![](https://img.shields.io/npm/v/fanfou-sdk-browser.svg)](https://www.npmjs.com/package/fanfou-sdk-browser)
[![](https://img.shields.io/npm/l/fanfou-sdk-browser.svg)](https://github.com/fanfoujs/fanfou-sdk-browser/blob/master/LICENSE)
[![](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo)

Fanfou SDK for browser

## Install

```bash
$ npm i fanfou-sdk-browser
```

---

<a href="https://www.patreon.com/LitoMore">
  <img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
</a>

## Usage

```javascript
import Fanfou from 'fanfou-sdk-browser'
```

**OAuth**

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

  const timeline = await ff.get('/statuses/home_timeline', {format: 'html'})
})();
```

**XAuth**

```javascript
(async () => {
  const ff = new Fanfou({
    consumerKey: '',
    consumerSecret: '',
    username: '',
    password: ''
  });

  await ff.xauth();

  const publimeTimeline = await ff.get('/statuses/public_timeline', {count: 10})
  const status = await ff.post('/statuses/update', {status: 'Hi Fanfou'})
})();
```

**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 protocol, default is `''`
- `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](https://github.com/FanfouAPI/FanFouAPIDoc/wiki).

## API

```javascript
ff.getRequestToken()
ff.getAccessToken(token)
ff.xauth()
ff.get(uri, params)
ff.post(uri, params)
ff.upload(uri, params)
```

**Examples**

```javascript
(async () => {
  // Get request token
  const token = await ff.getRequestToken();

  // Get access token
  const token = await ff.getAccessToken({oauthToken: '', oauthTokenSecret: ''});

  // Get timeline
  const timeline = await ff.get('/statuses/home_timeline', {});

  // Post status
  const status = await ff.post('/statuses/update', {status: 'post test'});

  // Upload photo
  const result = await ff.upload('/photos/upload', {photo: uploadFile, status: 'unicorn'});
})();
```

**Tips**

Use `hooks` for your reverse-proxy server

```javascript
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

- [fanfou-pro](https://github.com/LitoMore/fanfou-pro) - A Web App Fanfou client
- [x-fan](https://github.com/LitoMore/x-fan) - A Fanfou client with Framework7
- [fanfou-sdk-node](https://github.com/fanfoujs/fanfou-sdk-node) - Fanfou SDK for Node.js
- [fanfou-sdk-deno](https://github.com/LitoMore/fanfou-sdk-deno) - Fanfou SDK for Deno
- [fanfou-sdk-weapp](https://github.com/fanfoujs/fanfou-sdk-weapp) - Fanfou SDK for WeApp
- [fanfou-sdk-python](https://github.com/LitoMore/fanfou-sdk-python) - Fanfou SDK for Python
- [ky](https://github.com/sindresorhus/ky) - Tiny and elegant HTTP client based on the browser Fetch API

## License

MIT

---
_Source: https://npm.io/package/fanfou-sdk-browser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
