Git Product home page Git Product logo

node-weixin-media's Introduction

NPM version Build Status Dependency Status Coveralls Status

Media Api for weixin

微信多媒体API

微信多媒体API是(node-weixin-api 或者 node-weixin-express)的一个子项目。 它提供:

  1. 菜单API共计7个:

temporary.create: 上传多媒体(临时)

temporary.get: 获取多媒体(临时)

permanent.news: 获取

permanent.create: 上传多媒体(永久)

permanent.get: 获取多媒体(永久)

permanent.remove: 删除多媒体(永久)

permanent.update: 更新多媒体(永久)

count: 获取组列表

list: 创建新组

  1. 所有数据返回格式采用json,并与腾讯api上说明一致。回调函数格式如下: function(error, json) { //error为false表示返回正常 //json对应api说明 }

注:

交流QQ群: 39287176

node-weixin-express是基于node-weixin-*的服务器端参考实现。

node-weixin-api是基于node-weixin-*的API接口SDK。

它们都是由下列子项目组合而成:

  1. node-weixin-config 用于微信配置信息的校验

  2. node-weixin-auth 用于与微信服务器握手检验

  3. node-weixin-util 一些常用的微信请求,加密,解密,检验的功能与处理

  4. node-weixin-request 微信的各类服务的HTTP请求的抽象集合

  5. node-weixin-oauth 微信OAuth相关的操作

  6. node-weixin-pay 微信支付的服务器接口

  7. node-weixin-jssdk 微信JSSDK相关的服务器接口

  8. node-weixin-menu 微信菜单相关的操作与命令

  9. node-weixin-user 微信用户API

  10. node-weixin-media 微信多媒体API

  11. node-weixin-link 微信推广(二维码,URL)API

Install

$ npm install --save node-weixin-media

Usage

var media = require('node-weixin-media');
var app = {
  id: process.env.APP_ID,
  secret: process.env.APP_SECRET,
  token: process.env.APP_TOKEN
};
var auth = require("node-weixin-auth");
var config = require("node-weixin-config");
config.app.init(app);

###创建临时多媒体 接口文档

var file = path.resolve(__dirname, "media/image.jpg");
media.temporary.create(app, auth, 'image', file, function (error, json) {
  //json.type
  //json.media_id
});

###获取临时多媒体 接口文档

var file = path.resolve(__dirname, "output/temporary.jpg");
media.temporary.get(app, auth, mediaId, file, function (error) {
});

###创建永久多媒体 接口文档

var file = path.resolve(__dirname, "media/image.jpg");
media.permanent.create(app, auth, 'image', file, function (error, json) {
  //json.media_id
  //json.url
});

###获取永久多媒体 接口文档

media.permanent.get(app, auth, mediaId, function (error, body) {
  var file = path.resolve(__dirname, "permanent.jpg");
  fs.writeFileSync(file, new Buffer(body));
});

###创建永久图文素材 接口文档

var json =     {
  "media_id": newsId,
  "index": 0,
  "articles": {
    "title": 'hello1',
    "thumb_media_id": mediaId,
    "author": 'author2',
    "digest": 'digest1',
    "show_cover_pic": 0,
    "content": 'content1',
    "content_source_url": 'http://www.sina.com.cn'
  }
};
media.permanent.update(app, auth, json, function (error, data) {
});

###更新永久图文素材 接口文档

var json = {
  "media_id": newsId,
  "index": 0,
  "articles": {
    "title": 'hello1',
    "thumb_media_id": mediaId,
    "author": 'author2',
    "digest": 'digest1',
    "show_cover_pic": 0,
    "content": 'content1',
    "content_source_url": 'http://www.sina.com.cn'
  }
};
media.permanent.update(app, auth, json, function (error, data) {

});

###删除永久素材 接口文档

media.permanent.remove(app, auth, newsId/mediaId, function (error, data) {
});

###获取素材总数 接口文档

media.count(app, auth, function (error, json) {
  //json.voice_count
  //json.video_count
  //json.image_count
  //json.news_count
});

###获取素材总数 接口文档

media.count(app, auth, function (error, json) {
  //json.voice_count
  //json.video_count
  //json.image_count
  //json.news_count
});

###获取素材列表 接口文档

media.permanent.remove(app, auth, newsId, function (error, data) {
});
$ npm install --global node-weixin-media
$ node-weixin-media --help

License

MIT © node-weixin

node-weixin-media's People

Contributors

calidion avatar

Watchers

lgyt34 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.