Skip to main content

fanfou-sdk-python

Fanfou SDK for Python

Install

pip install fanfou_sdk

Usage

OAuth

from fanfou_sdk import Fanfou

ff = Fanfou(
    consumer_key='',
    consumer_secret='',
    oauth_token='',
    oauth_token_secret=''
)

result, response = ff.get('/statuses/home_timeline', {'format': 'html'})
print(result, response)

XAuth

ff = Fanfou(
  consumer_key='',
  consumer_secret='',
  username='',
  password=''
)

token, response = ff.xauth()
print(token, response)

timeline, _ = ff.get('/statuses/public_timeline', {'count': 10})
print(timeline)

status, _ = ff.post('/statuses/update', {'status': 'Hi Fanfou'})
print(status)

Options

  • consumer_key: The consumer key
  • consumer_secret: The consumer secret
  • oauth_token: The OAuth token
  • oauth_token_secret: The OAuth token secret
  • username: The Fanfou username
  • password: The Fanfou password
  • protocol: Set the prototol, default is http:
  • api_domain: Set the API domain, default is api.fanfou.com
  • oauth_omain: 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

ff.request_token()
ff.access_token(token)
ff.xauth()
ff.get(uri, params={})
ff.post(uri, params={}, files=None)

Examples

# Get request token
token, _ = ff.request_token()
print(token)

# Get access token
token, _ = ff.access_token()
print(token)

# Get timeline
tl, _ = ff.get('/statuses/home_timeline')
print(tl)

# Post status
st, _ = ff.post('/statuses/update', {status: 'hi flora'})
print(st)

# Upload photo
st, _ = ff.post(
  '/photos/upload',
  params={'status': 'unicorn'},
  files={'photo': open('file_path', 'rb')}
)
print(st)

Tips

Use hooks for your reverse-proxy server

ff = Fanfou(
  consumer_key='',
  consumer_secret='',
  oauth_token='',
  oauth_token_secret='',
  api_domain='api.example.com',
  oauth_domain='example.com',
  hooks={
    'base_string': lambda s: s.replace('example.com', 'fanfou.com')
  }
)

Related

License

MIT

Release files for fanfou-sdk 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fanfou-sdk 0.0.3
File Size Uploaded
fanfou_sdk-0.0.3.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fanfou-sdk 0.0.3
File Interpreter ABI Platform
fanfou_sdk-0.0.3-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 10.8 kB

Release files / fanfou_sdk-0.0.3.tar.gz

Download URL fanfou_sdk-0.0.3.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b38b1be8ddfd522867b02f8c0904d24f7492eee4a8f39644ded81f1394352d75
BLAKE2b-256 checksum
How to use checksums
8631933b6760fd70288e694bf4a476004efec28f87e308d544cfc25ff0e5016b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / fanfou_sdk-0.0.3-py2.py3-none-any.whl

Download URL fanfou_sdk-0.0.3-py2.py3-none-any.whl
Size 5.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
b3b3e4201198d0edb5e0e24ef54ca82aebb86a50a1c6b78c45d75be72a3ba72e
BLAKE2b-256 checksum
How to use checksums
feb8c4784becd5e2452fe616a45b760cb490e08b64e9784618b08bf5071f375b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page