GithubHelp home page GithubHelp logo

weixinapi's Introduction

WeixinAPI

Another Weixin WebView API


微信API封装, finscn ( @大城小胖 ) 版.

参考了 https://github.com/zxlie/WeixinApi 的实现, 但做了非常大的改动,所以没有fork。

和 zxlie版本比 ,代码方面设计思路不同, 代码体积更小.

其他的详见代码注释 和 example 吧.

已知bug

微信 5.4 Android版下, 分享到朋友圈时, 总是返回ok, 且返回两次.疑似微信android版本的bug.

建议在 shareTimeline 的 ready事件中做回调, 避免重复操作.


简单示例:


var weixin = new WeixinAPI({
    timeout: 2500,
    onReady: function() {
        $id("weixinState").innerHTML = "WeixinAPI is ready";
    },
    onTimeout: function() {
        $id("weixinState").innerHTML = "WeixinAPI is timeout";
    }
});
weixin.init();



var shareData = {
    title: "标题: 测试",
    desc: "描述: WeixinAPI 大城小胖 版 测试.",
    img_url: weixin.getAbsolutePath("share-icon.jpg")
};

weixin.generalShare(shareData, {
    ready: function(shareData, action) {
        alert(action+" 操作 准备好了:" + shareData.title || shareData.desc);
    },
    cancel: function(resp, action) {
        alert(action+" 操作 被取消 了." + resp.err_msg);
    },
    succeed: function(resp, action) {
        alert(action+" 操作 成功 了." + resp.err_msg);
    },
    fail: function(resp, action) {
        alert(action+" 操作 失败 了." + resp.err_msg);
    },
    complate: function(resp, action) {
        alert(action+" 结束 了." + resp.err_msg);
    },
});

weixinapi's People

Contributors

finscn avatar

Watchers

 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.