Git Product home page Git Product logo

mp-music's Introduction

mp-music

Introduction

微信公众号接入音乐 API

其实应该很多人都做过了。只是无聊又想给自己的订阅号接入一下。

Run

git clone [repo]
pipenv install

config/setting.py 下新增 TOKEN='xxxx' 与公众号配置的 TOKEN 一致。

app/config 目录下新建 secure.py 新增 TOKEN='xxxx' 与公众号配置的 TOKEN 一致

pipenv shell
python manage.py

Deploy

mpmusic 为 nginx 配置文件放置于 /etc/nginx/sites-enabled/mpmusic

mpmusic.conf 为 supervisor 配置文件放置于 /etc/supervisor/conf.d/mpmusic.conf

为了让 Click 在 Unix 以及 Python3 环境下能够正确处理编码问题,我们需要将环境变量 LC_ALL 和 LANG 设为 C.UTF-8 或 en_US.UTF-8,在 supervisord.conf 配置文件写入 -- 参考 《flask web 开发实战》

sudo vim /etc/supervisor/supervisord.conf
# 在 [supervisord] 下面添加
environment=LC_ALL='en_US.UTF-8',LANG='en_US.UTF-8'

Demo

music

Change Log

  • Tue Sep 17 17:51:55 CST 2019 third version

增加 redis 缓存 因为个人订阅号没有办法使用客服接口?

  • 2019年 09月 13日 星期五 01:46:35 CST second version
  • Tue Apr 2 02:13:13 first version

Acknowledgement

mp-music's People

Contributors

ronething avatar

Stargazers

 avatar

Watchers

 avatar

mp-music's Issues

chore

  • 返回信息 content-type 不一定要 text/xml
  • 解析消息的方式不好 可以参考
type_fields = {
    "text": ["ToUserName", "FromUserName", "CreateTime", "MsgType", "Content", "MsgId", "AgentID"],
    "image": ["ToUserName", "FromUserName", "CreateTime", "MsgType", "PicUrl", "MediaId", "MsgId", "AgentID"]
}
xml_tree = ET.fromstring(xml_content)
type_name = xml_tree.find("MsgType").text
msg = {}
for nodename in type_fields[type_name]:
    msg[nodename] = xml_tree.find(nodename).text
  • 不使用明文模式

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.