GithubHelp home page GithubHelp logo

duoshuo-python-sdk's Introduction

Banner

Duoshuo Python SDK

多说Python SDK支持用Python语言开发的网站,对其提供[多说]插件的支持。使用中遇到的问题请到多说开发者中心提问

Requirements

Python 2.6+

Django 1.6+ (如果在Django中使用)

Install

python setup.py install

Index

Python Useage

Django useage

Python Usage

作为Python models来使用

Core (init.py)

sdk核心功能: 交换token,生成授权链接,调用api接口

实例化duoshuoAPI

from duoshuo import DuoshuoAPI

api = DuoshuoAPI(short_name=YOUR_DUOSHUO_SHORT_NAME, secret=YOUR_DUOSHUO_SECRET)

#例如要获取用户信息
api.users.profile(user_id=1)

更多API可以查看多说开发文档

交换token

访问需要登录的接口时要先进行授权,采用OAuth2.0协议,Python SDK提供交换token的处理,实例化api后可以直接传入code来获取token:

code = request.GET.get('code') #获得GET参数(以Django为例)

token = api.get_token(code=code)

Django Usage

作为Django app来使用

安装duoshuo插件

# settings.py
INSTALLED_APPS = (
    ...
    'duoshuo',
)

DUOSHUO_SECRET = '你的多说secret,在多说管理后台 - 设置 - 密钥'
DUOSHUO_SHORT_NAME = '你的多说short name,比如你注册了example.duoshuo.com,short name就是example'

显示多说评论框

{% load duoshuo_tags %}

{% duoshuo_comments %}

#给多说评论框传递其他short name
{% duoshuo_comments '其他short name' %}

duoshuo-python-sdk's People

Contributors

imom0 avatar perchouli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

duoshuo-python-sdk's Issues

评论框的样式的问题

你们最近是不是修改了评论部分,填写用户名和邮箱部分的样式。导致的结果是填入文字之后无法显示,我自己在博客上reset你们部分样式:

/*reset duoshuo */
#ds-wrapper #ds-reset .ds-control-group {
    max-width: 277px !important;
}
#ds-wrapper #ds-reset .ds-control-group input {
    padding: 4px 0px 6px 6px !important;
}

不知道是你们有修改样式,还是我升级css到bootstrap导致的。

另外,多说评论做的很赞!

No such file or directory: 'PKG_PATH/interfaces.json'

command:

python manage.py runserver 0.0.0.0:8088

traceback:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/tianyu/.virtualenvs/buzz/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/Users/tianyu/.virtualenvs/buzz/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/tianyu/.virtualenvs/buzz/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Users/foo/.virtualenvs/buzz/lib/python2.7/site-packages/django/core/management/base.py", line 280, in execute
    translation.activate('en-us')
  File "/Users/foo/.virtualenvs/buzz/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 130, in activate
    return _trans.activate(language)
  File "/Users/foo/.virtualenvs/buzz/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 188, in activate
    _active.value = translation(language)
  File "/Users/foo/.virtualenvs/buzz/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 177, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)
  File "/Users/foo/.virtualenvs/buzz/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 159, in _fetch
    app = import_module(appname)
  File "/Users/foo/.virtualenvs/buzz/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "/Users/foo/.virtualenvs/buzz/lib/python2.7/site-packages/duoshuo_python_sdk-0.1-py2.7.egg/duoshuo/__init__.py", line 37, in <module>
    INTERFACES = _parse_json(open(os.path.join(os.path.dirname(__file__), 'interfaces.json'), 'r').read())
IOError: [Errno 2] No such file or directory: '/Users/foo/.virtualenvs/buzz/lib/python2.7/site-packages/duoshuo_python_sdk-0.1-py2.7.egg/duoshuo/interfaces.json'

我进到目录/Users/foo/.virtualenvs/buzz/lib/python2.7/site-packages/duoshuo_python_sdk-0.1-py2.7.egg/duoshuo/i下ls查看确实没有json文件

似乎是setup.py脚本里有点问题

PS,我是从github安装的:pip install git+https://github.com/duoshuo/duoshuo-python-sdk.git

环境:
python 2.7
django 1.6.5

SSO登录不支持百度和谷歌?

我根据http://dev.duoshuo.com/threads/5023323ce9b7bde608000012这个页面的说明,在我的网站设置SSO登录。在我的网站的登录页面我放置了,但是出现的社交帐号登录选择没有百度和谷歌的,而在多说评论框的登录有百度和谷歌这两个选项。

另外,所出现的社交帐号登录选择的图标和多说评论框的图标不一样,比如QQ那个,前者的图片是一个圈,后者的图标是个企鹅。

希望管理员能同步SSO登录和多说评论框登录。

python3 不能安装

执行python setup.py install 就出现UnicodeDecodeError。
这个项目是不是没人维护了?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.