Fanfou SDK for Python
pip install fanfou_sdk
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)
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)
consumer_key
: The consumer keyconsumer_secret
: The consumer secretoauth_token
: The OAuth tokenoauth_token_secret
: The OAuth token secretusername
: The Fanfou usernamepassword
: The Fanfou passwordprotocol
: Set the prototol, default ishttp:
api_domain
: Set the API domain, default isapi.fanfou.com
oauth_omain
: Set the OAuth domain, default isfanfou.com
hooks
: Hooks allow modifications with OAuth
For more Fanfou API docs, see the Fanfou API doc.
ff.request_token()
ff.access_token(token)
ff.xauth()
ff.get(uri, params={})
ff.post(uri, params={}, files=None)
# 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)
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')
}
)
- fanfou-sdk-node - Fanfou SDK for Node.js
- fanfou-sdk-deno - Fanfou SDK for Deno
- fanfou-sdk-browser - Fanfou SDK for browser
- fanfou-sdk-weapp - Fanfou SDK for WeApp
MIT