Swift 生成小程序二维码

// // 获取小程序全局唯一后台接口调用凭据(access_token)

   let weixin_getAccessToken_path :String = "https://api.weixin.qq.com/cgi-bin/token?grant_type=" + "client_credential" + "&appid="  + "wx677640643CCCC" + "&secret=" + "929c9e16cb5114f365b74cbXXXX"

   Alamofire.request(weixin_getAccessToken_path, method: .get, parameters: nil, encoding: URLEncoding.default, headers: nil).responseJSON { (response) in

     if response.error == nil, let value = response.result.value as? Dictionary, let token  = value["access_token"] as? String{
//
//                NSLog("请求成功")
//                // 获取小程序码,适用于需要的码数量极多的业务场景。通过该接口生成的小程序码,永久有效,数量暂无限制
           let wxacodeunlimit_path :String = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + token

      Alamofire.request( wxacodeunlimit_path, method: .post, parameters: ["page":pagetype,"scene":scenetype], encoding: JSONEncoding.default, headers: nil).responseJSON { (response) in

          if let value = response.data {
                   shareUI.qrCodeImgView.image = UIImage(data: value)
                   NSLog("请求成功:----")
//                        // LLog("请求成功")
     }  }   }}

你可能感兴趣的:(Swift 生成小程序二维码)