Skip to main content

Fanfou SDK for Python

Project description

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.xauth()
ff.get(uri, params={})
ff.post(uri, params={}, files=None)

Examples

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

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

st, _ = ff.post(
  '/statuses/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 str: str.replace('example.com', 'fanfou.com')
  }
)

Related

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fanfou_sdk-0.0.1.tar.gz (5.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page