Code Monkey home page Code Monkey 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

perchouli avatar imom0 avatar

Watchers

James Cloos avatar  avatar

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.