# fanfou-sdk-python
[![](https://github.com/LitoMore/fanfou-sdk-python/workflows/CI/badge.svg)](https://github.com/LitoMore/fanfou-sdk-python/actions)
[![](https://img.shields.io/pypi/v/fanfou-sdk)](https://pypi.org/project/fanfou-sdk)
[![](https://img.shields.io/pypi/l/fanfou-sdk)](https://github.com/LitoMore/fanfou-sdk-python/blob/master/LICENSE)
Fanfou SDK for Python
## Install
```shell
pip install fanfou_sdk
```
## Usage
### OAuth
```python
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
```python
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](https://github.com/FanfouAPI/FanFouAPIDoc/wiki).
## API
```
ff.request_token()
ff.access_token(token)
ff.xauth()
ff.get(uri, params={})
ff.post(uri, params={}, files=None)
```
### Examples
```python
# 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
```python
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
- [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-browser](https://github.com/fanfoujs/fanfou-sdk-browser) - Fanfou SDK for browser
- [fanfou-sdk-weapp](https://github.com/fanfoujs/fanfou-sdk-weapp) - Fanfou SDK for WeApp
## License
MIT
Raw data
{
"_id": null,
"home_page": "https://github.com/LitoMore/fanfou-sdk-python",
"name": "fanfou-sdk",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "fanfou",
"author": "LitoMore",
"author_email": "litomore@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/86/31/933b6760fd70288e694bf4a476004efec28f87e308d544cfc25ff0e5016b/fanfou_sdk-0.0.3.tar.gz",
"platform": "any",
"description": "# fanfou-sdk-python\n\n[![](https://github.com/LitoMore/fanfou-sdk-python/workflows/CI/badge.svg)](https://github.com/LitoMore/fanfou-sdk-python/actions)\n[![](https://img.shields.io/pypi/v/fanfou-sdk)](https://pypi.org/project/fanfou-sdk)\n[![](https://img.shields.io/pypi/l/fanfou-sdk)](https://github.com/LitoMore/fanfou-sdk-python/blob/master/LICENSE)\n\nFanfou SDK for Python\n\n## Install\n\n```shell\npip install fanfou_sdk\n```\n\n## Usage\n\n### OAuth\n\n```python\nfrom fanfou_sdk import Fanfou\n\nff = Fanfou(\n consumer_key='',\n consumer_secret='',\n oauth_token='',\n oauth_token_secret=''\n)\n\nresult, response = ff.get('/statuses/home_timeline', {'format': 'html'})\nprint(result, response)\n```\n\n### XAuth\n\n```python\nff = Fanfou(\n consumer_key='',\n consumer_secret='',\n username='',\n password=''\n)\n\ntoken, response = ff.xauth()\nprint(token, response)\n\ntimeline, _ = ff.get('/statuses/public_timeline', {'count': 10})\nprint(timeline)\n\nstatus, _ = ff.post('/statuses/update', {'status': 'Hi Fanfou'})\nprint(status)\n```\n\n### Options\n\n- `consumer_key`: The consumer key\n- `consumer_secret`: The consumer secret\n- `oauth_token`: The OAuth token\n- `oauth_token_secret`: The OAuth token secret\n- `username`: The Fanfou username\n- `password`: The Fanfou password\n- `protocol`: Set the prototol, default is `http:`\n- `api_domain`: Set the API domain, default is `api.fanfou.com`\n- `oauth_omain`: Set the OAuth domain, default is `fanfou.com`\n- `hooks`: Hooks allow modifications with OAuth\n\n> For more Fanfou API docs, see the [Fanfou API doc](https://github.com/FanfouAPI/FanFouAPIDoc/wiki).\n\n## API\n\n```\nff.request_token()\nff.access_token(token)\nff.xauth()\nff.get(uri, params={})\nff.post(uri, params={}, files=None)\n```\n\n### Examples\n\n```python\n# Get request token\ntoken, _ = ff.request_token()\nprint(token)\n\n# Get access token\ntoken, _ = ff.access_token()\nprint(token)\n\n# Get timeline\ntl, _ = ff.get('/statuses/home_timeline')\nprint(tl)\n\n# Post status\nst, _ = ff.post('/statuses/update', {status: 'hi flora'})\nprint(st)\n\n# Upload photo\nst, _ = ff.post(\n '/photos/upload',\n params={'status': 'unicorn'},\n files={'photo': open('file_path', 'rb')}\n)\nprint(st)\n```\n\n### Tips\n\nUse `hooks` for your reverse-proxy server\n\n```python\nff = Fanfou(\n consumer_key='',\n consumer_secret='',\n oauth_token='',\n oauth_token_secret='',\n api_domain='api.example.com',\n oauth_domain='example.com',\n hooks={\n 'base_string': lambda s: s.replace('example.com', 'fanfou.com')\n }\n)\n```\n\n## Related\n\n- [fanfou-sdk-node](https://github.com/fanfoujs/fanfou-sdk-node) - Fanfou SDK for Node.js\n- [fanfou-sdk-deno](https://github.com/LitoMore/fanfou-sdk-deno) - Fanfou SDK for Deno\n- [fanfou-sdk-browser](https://github.com/fanfoujs/fanfou-sdk-browser) - Fanfou SDK for browser\n- [fanfou-sdk-weapp](https://github.com/fanfoujs/fanfou-sdk-weapp) - Fanfou SDK for WeApp\n\n## License\n\nMIT\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Fanfou SDK for Python",
"version": "0.0.3",
"project_urls": {
"Homepage": "https://github.com/LitoMore/fanfou-sdk-python"
},
"split_keywords": [
"fanfou"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "feb8c4784becd5e2452fe616a45b760cb490e08b64e9784618b08bf5071f375b",
"md5": "59017a3636a0c21e4de4638c2e41821f",
"sha256": "b3b3e4201198d0edb5e0e24ef54ca82aebb86a50a1c6b78c45d75be72a3ba72e"
},
"downloads": -1,
"filename": "fanfou_sdk-0.0.3-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "59017a3636a0c21e4de4638c2e41821f",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 5764,
"upload_time": "2023-07-14T16:37:34",
"upload_time_iso_8601": "2023-07-14T16:37:34.491004Z",
"url": "https://files.pythonhosted.org/packages/fe/b8/c4784becd5e2452fe616a45b760cb490e08b64e9784618b08bf5071f375b/fanfou_sdk-0.0.3-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8631933b6760fd70288e694bf4a476004efec28f87e308d544cfc25ff0e5016b",
"md5": "82b38bea7cacaa7a8673322b5c48a865",
"sha256": "b38b1be8ddfd522867b02f8c0904d24f7492eee4a8f39644ded81f1394352d75"
},
"downloads": -1,
"filename": "fanfou_sdk-0.0.3.tar.gz",
"has_sig": false,
"md5_digest": "82b38bea7cacaa7a8673322b5c48a865",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5039,
"upload_time": "2023-07-14T16:37:35",
"upload_time_iso_8601": "2023-07-14T16:37:35.818430Z",
"url": "https://files.pythonhosted.org/packages/86/31/933b6760fd70288e694bf4a476004efec28f87e308d544cfc25ff0e5016b/fanfou_sdk-0.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-14 16:37:35",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "LitoMore",
"github_project": "fanfou-sdk-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "fanfou-sdk"
}