• 微信小程序开发


    官方api  https://mp.weixin.qq.com/debug/wxadoc/dev/api/api-network.html

    1 注册微信小程序帐号 

    2 下载开发工具 链接  https://mp.weixin.qq.com/debug/wxadoc/dev/devtools/download.html

    3 登录开发工具,填写appid ,开始开发

    备注 获取 openid

    public static String getOpenid(String code){
    Map<String, Object> map = new HashMap<>();
    map.put("appid", WxConfig.appid);
    map.put("secret", WxConfig.secret);
    map.put("js_code", code);
    map.put("grant_type", WxConfig.grant_type);
    String jsons = SysUtil.getUrlResult(WxConfig.url, map , "POST");
    JSONObject js= JSONObject.parseObject(jsons);
    return js==null?"":js.getString("openid");
    }

     getUrlResult 工具方法

    /**
    *
    * @param urlStr
    * url
    * @param content
    * 提交的参数
    * @param encoding
    * 编码格式
    * @return
    */

    public static String getUrlResult(String urlStr, Map<String,Object> map,String method) {
    URL url = null;
    HttpURLConnection connection = null;
    try {
    url = new URL(urlStr);
    connection = (HttpURLConnection) url.openConnection();// 新建连接实例
    connection.setConnectTimeout(10000);// 设置连接超时时间,单位毫秒
    connection.setReadTimeout(10000);// 设置读取数据超时时间,单位毫秒
    connection.setDoOutput(true);// 是否打开输出流 true|false
    connection.setDoInput(true);// 是否打开输入流true|false
    connection.setRequestMethod(method);// 提交方法POST|GET
    connection.setUseCaches(false);// 是否缓存true|false
    connection.connect();// 打开连接端口
    DataOutputStream out = new DataOutputStream(
    connection.getOutputStream());// 打开输出流往对端服务器写数据
    String content=buildUrlQuery(map);
    out.writeBytes(content);// 写数据,也就是提交你的表单 name=xxx&pwd=xxx
    out.flush();// 刷新
    out.close();// 关闭输出流
    BufferedReader reader = new BufferedReader(new InputStreamReader(
    connection.getInputStream(), "UTF-8"));// 往对端写完数据对端服务器返回数据
    // ,以BufferedReader流来读取
    StringBuffer buffer = new StringBuffer();
    String line = "";
    while ((line = reader.readLine()) != null) {
    buffer.append(line);
    }
    reader.close();
    return buffer.toString();
    } catch (IOException e) {
    e.printStackTrace();
    } finally {
    if (connection != null) {
    connection.disconnect();// 关闭连接
    }
    }
    return "";
    }

    小程序支付

    1 登录微信小程序 申请支付

    2 申请成功腾讯会发邮件 给你,邮件里有商户账号密码

    3 登录微信商户平台 下载证书,配置api 密钥

    开始开发

    想要源码联系qq 2506715686

  • 相关阅读:
    收银钱箱弹出设置
    IOS4.0 实例练习时钟
    mysql 日期查询操作 copy
    ios 学习笔记 2
    SVN 不能移动 xx\entries 到 xx\entries
    做一个基于PHPCMS V9架构的商城
    基于JDBC API 的事务管理代码示例
    mysql 数据类型
    Discuz!NT CreditsOperationType
    spring 事务传播行为
  • 原文地址:https://www.cnblogs.com/syscn/p/7506658.html
Copyright © 2020-2023  润新知