11 Star 43 Fork 11

Stan / signature-wx-js-sdk

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

# signature-wx-js-sdk

Description

微信接入js-sdk请求授权获得签名接口

Sequence diagram

sequence-gram

Installation

  1. git clone https://gitee.com/sense7/signature-wx-js-sdk.git

Instructions

config appId & appSecret in signature.php

$appId = 'wxd0803523dcadc007';
$appSecret = '6413fed34058b3f6465ac07112cb96ca';

Use in nodejs

install axios

> npm install axios

install wx-js-sdk

> npm install weixin-js-sdk

define axios in main.js

import axios from 'axios'
Vue.prototype.$axios = axios;

use in code

var authUrl = 'http://www.stanwind.com/demo/'

this.$axios.get('http://localhost/signature.php?url=' + authUrl).then(redata => {
    var data = redata.data;
    wx.config({
      debug: false, 
      // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
      // 必填,公众号的唯一标识
      appId: data.appId, 
      // 必填,生成签名的时间戳
      timestamp: data.timestamp, 
       // 必填,生成签名的随机串
      nonceStr: data.nonceStr,
      // 必填,签名
      signature: data.signature,
       // 必填,需要使用的JS接口列表,所有JS接口列表
      jsApiList: ['checkJsApi', 'scanQRCode'] // 必填,需要使用的JS接口列表
    });
});

wx.error(function (res) {
    console.log('wx error->' + res.errMsg);
});

wx.ready(function () {
    wx.checkJsApi({
        jsApiList: ['scanQRCode'],
        success: function (res) {
            console.log('check js api -> ' + res.errMsg);
        }
    });

    //微信方式
    wx.scanQRCode({
        needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
        scanType: ["barCode"], // ["qrCode","barCode"]  可以指定扫二维码还是一维码,默认二者都有
        success: function (res) {
          var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
          //alert("扫描结果:"+result);
          console.log(result);
          var isbn = result.split(',')[1];
          alert(isbn);
        }
    });
}); 

Test API

http://www.stanwind.com/wx/signature.php?url=http://www.stanwind.com/demo

Demo Response

{
  appId: "wxd0803523dcadc007",
  timestamp: 1551237888,
  nonceStr: "wantongtest",
  signature: "565194473ed71928f8ac9ac7e40561ae31bff993",
  ticket: "LIKLckvwlJT9cWIhEQTwfC_L_JPglkNAJ6HDVuhbwpN-RbVVBcZib8sfe0I3to39DU1LiO5V4hwqIE3cepb51g",
  url: "http://www.stanwind.com/demo",
  code: "0"
}

Contribution

  1. Fork the repository
  2. Create Feat_xxx branch
  3. Commit your code
  4. Create Pull Request

Gitee Feature

  1. You can use Readme_XXX.md to support different languages, such as Readme_en.md, Readme_zh.md
  2. Gitee blog blog.gitee.com
  3. Explore open source project https://gitee.com/explore
  4. The most valuable open source project GVP
  5. The manual of Gitee https://gitee.com/help
  6. The most popular members https://gitee.com/gitee-stars/
MIT License Copyright (c) 2019 Stan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

㊙100行代码搞定微信JS-SDK签名,单个php部署,文件存储token和ticket 展开 收起
PHP
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
PHP
1
https://gitee.com/sense7/signature-wx-js-sdk.git
git@gitee.com:sense7/signature-wx-js-sdk.git
sense7
signature-wx-js-sdk
signature-wx-js-sdk
master

搜索帮助

14c37bed 8189591 565d56ea 8189591