个人案例
每日一句学英语Plus
每日一句,学高逼格英语
每日一句学英语扫码体验
懒猴文字识别
免费、高效地文字识别服务
文字识别扫码体验
- 微信支付APIv3图片上传(营销专用)接口试了各种办法一直报: SIGN_ERROR, 怎么办?
官方文档: https://pay.weixin.qq.com/doc/v3/partner/4012760240?from=https%3A%2F%2Fpay.weixin.qq.com%2Fdocs%2Fpartner%2Fapis%2Fmerchant-exclusive-coupon%2Fupload-image.html 爹爹们,谁能给个nodejs 上传图片(营销专用)接口能正常使用的代码? 调试到自闭了 const { KJUR, hextob64 } = require('jsrsasign') const axios = require('axios') const fs = require('fs') // 上传图片 async function upload(req, res, next) { try { const method = 'POST' const pathname = '/v3/marketing/favor/media/image-upload' const timestamp = Math.round(new Date().getTime() / 1000); // 十位的时间戳 const onece_str = await randomString() // 随机字符串 const bodyParamsStr = { filename: 'wechatpay_logo.png', sha256: 'd2973a45b1d528c21ebb77792ef3fcea40fa9a4e04a17e35369102ba9c84c8b1' } const mchid = '***' // 商户号 const serial_no = '***' // 商户API证书序列号 const private_key = `***`// appiclient_key.pem里的内容全部复制过来 const signature = await rsaSign(`${method}\n${pathname}\n${timestamp}\n${onece_str}\n${JSON.stringify(bodyParamsStr)}\n`, private_key, 'SHA256withRSA') //获取到signature后就可以获取到Authorization了 let Authorization = `WECHATPAY2-SHA256-RSA2048 mchid="${mchid}",nonce_str="${onece_str}",timestamp="${timestamp}",signature="${signature}",serial_no="${serial_no}"` const formData = new FormData(); formData.append('file', fs.createReadStream('./test.png')); formData.append('meta', bodyParamsStr); const data = await axios.post('https://api.mch.weixin.qq.com/v3/marketing/favor/media/image-upload', formData, { headers: { Authorization, 'Content-Type': 'multipart/form-data;boundary=boundary', 'Accept': 'application/json' } }) console.log(data); res.json(data.data) } catch (error) { console.log(error.response.data); // return next(error) } } // 加密 async function rsaSign(content, privateKey, hash = 'SHA256withRSA') { console.log(content, 11111); // 创建 Signature 对象 const signature = new KJUR.crypto.Signature({ alg: hash, //!这里指定 私钥 pem! prvkeypem: privateKey }) signature.updateString(content) const signData = signature.sign() // 将内容转成base64 return hextob64(signData) } // 生成随机数 async function randomString(e = 32) { const t = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678' const a = t.length let n = '' for (let index = 0; index < e; index++) { n += t.charAt(Math.floor(Math.random() * a)) } return n.toUpperCase() } upload() 报错: { code: 'SIGN_ERROR', detail: { detail: { issue: 'sign not match' }, field: 'signature', location: 'authorization', sign_information: { method: 'POST', sign_message_length: 104, truncated_sign_message: 'POST\n' + '/v3/marketing/favor/media/image-upload\n' + '1751199760\n' + 'KETTK3NNYARDZFHEXWNQRFBYQNP4BXYS\n' + '[object \n', url: '/v3/marketing/favor/media/image-upload' } }, message: '错误的签名,验签失败' }
06-29 - 腾讯官方小程序插件"微信支付券"的文档访问不了啦
https://mp.weixin.qq.com/wxopen/plugindevdoc?appid=wxf3f436ba9bd4be7b&token=&lang=zh_CN 腾讯官方小程序插件"微信支付券"的文档访问不了啦 以下两个链接都无法正常访问: [图片]
06-20 - 小程序首页使用web-view组件后,额外再写入与页面相关的wxml文本内容,这样SEO录首页吗?
根据 小程序搜索优化指南 https://https://developers.weixin.qq.com/miniprogram/dev/framework/search/seo.html ,web-view 中的任何内容不会被收录,我现在有如下代码: <web-view src="{{link}}" style="width:100vw;height:100vh"></web-view> <view> 快乐足球 </view> 我知道由于webview的独占性,"快乐足球"不会在界面上显示。 我的问题是:这种情况下“快乐足球”会被搜索引擎收录吗?
05-29 - 为什么 wx.getFuzzyLocation 同意授权后, 每次重新进入小程序都要弹出授权框?
小程序appid: wx7b6aabda94dc2a23
2024-03-16 - 小程序内容区域覆盖顶部navigationBar
发现一个小程序: 印象画板 (可微信搜索查看), 它的小程序内容区域(应该是canvas)覆盖顶部navigationBar,是如何实现的?
2018-07-23