主机参考:VPS测评参考推荐/专注分享VPS服务器优惠信息!若您是商家可以在本站进行投稿,查看详情!此外我们还提供软文收录、PayPal代付、广告赞助等服务,查看详情! |
我们发布的部分优惠活动文章可能存在时效性,购买时建议在本站搜索商家名称可查看相关文章充分了解该商家!若非中文页面可使用Edge浏览器同步翻译!PayPal代付/收录合作 |
这次,我们将介绍微信共享功能的开发。 有哪些预防措施用于开发微信分享功能?以下是一个实际情况。让我们看看。
在微信中嵌入的网页在右上角具有默认的共享功能。 如下图所示,第一个图像是自定义效果,第二张图像是默认效果。 人们是否想通过启用自定义共享链接来点击? 开发过程将在下面说明。
1。准备配置JS接口安全域名。这需要使用微信的JSSDK。 必须将其设置为您的微信公共帐户的背景。官方帐户设置- ->功能设置- -> JS接口安全域名。 打开此页面后,将提示您:必须先下载此文件并将其上传到指定域名的根目录。
此文件是一个字符串,用于基于名称的验证。 您可以通过首先上传成功保存此文件。 这使您可以使用JSSDK。
2。前端配置
要解释的第一件事是共享功能是配置功能,当绑定到按钮单击事件时,没有效果。 换句话说,只有单击右上角的共享(我不知道如何实现文本内容的共享)才能有效。 JS官方有四个步骤。 第一个是JSSDK:
脚本src = http://res.wx.qq.com/open/js/jweixin - set; }公共字符串noncestr {get;放; } public long timestamp {get;放; }公共字符串签名{get;放; }公共字符串票{get;放; }公共stwist url {get;放; } public void makeign(){var string1builder = new StringBuilder(); string1builder.append(jsapi_ticket =)。append(ticke).append()。append(noncester =)。append()。append()。append()。 var string1 = string1builder.tostring(); signature = util.sha1(string1,encoding.default); }
然后配置:
wx.config({debug:true,//打开调试模式,所有称为API的返回值都会被提醒到客户端。要在PC侧打开它们,参数信息将通过日志打印,将通过日志打印,只有PC端的标识才能打印出来。 // signature signature signature: '@model.signature', // need, signature, signature, Jsapilist: [Checkjsapi, onmenretimeline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, onmenusheline, Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenusheline,Onmenushe,Onmenushe,OnmenusheeENUSHAREQQ,ONMENUSHAREQZONE] //您需要使用所需的JS接口列表,请参见附录2}); wx.ready(function(){document.querySelector('#checkjsapi')。 //链接imgurl:'http://www.ward.com/images/s1.jpg alert(json.stringify(res));默认链接dataurl:'',//如果类型是音乐或视频,则必须提供默认情况下的数据链接。 获取Access_Token和JSAPI_Ticket生成正确的签名。 https://api.weixin.qqc.com/cgi - bin/token?grant_type = crient_credential appid = {0} secret = {1} public tokenResult tokenresult getAccestoken() string.format(wxdeviceconfig.accestokenurlll,wxdevicecontedurl,wxdevicecontedurl wxdeviconfig.appsecret); jsapi_ticket
access_token是获取jsapi_ticketRL:https://api.weixin.qq.com/cgi - bin/ticke/getTicket? access_token = access_token&type = jsapi,返回的json对象是:
{errcode:0,errmsg:ok ok,ticket:bxldikrxvbtpdpdhsm05e5e5e5suoxnkd8 - 41ZO3MHKOYN5OFKWITDGGNR2FWJ0M9E8NYZWKVZVZVZVZVDVTAUUGWVSDSHFKA,型号:
公共类JsapiticketModel {public string {public string erncode {get;放; } public String errmsg {get;放; }公共字符串Expires_in {get;放; }}
如何完成门票完成:
public jsapiticketModel getjSapiticket(String accessToken){var url = string.format(wxpayConfig.jsapi_ticketurl,accessToken);返回sendhelp.send jsapiticketModel(accessToken,url,commonjSonsendType.get); }
门票也已到期7200秒,不能经常要求,因此也必须在服务器端缓存。
私有void setCacheticket(字符串缓存)_cachemanager.set(toKenkey,Cache,7200); }
MemoryCacheManager:
查看代码
您终于到达了这一点,并在文档中看到了一个让您失望的场景。为什么未提供JSSDK?好吧,现在,不要抱怨。 官员们还解释了签署规则。 首先是https://github.com/night - king/weixinsdk:
public static String sha1(字符串orgstr,string concode = utf - 8){var sha1 = new sha1 = new sha1managed(); var sha1bytes = system.text.encoding.getencoding(encode).getBytes(orgstr); byte [] resulthash = sha1.computehash(sha1bytes);字符串sha1string = bitConverter.toString(resultash).tolower(); sha1string = sha1string.replace([-,返回sha1string;} //示例错误
结果与正式验证不一致。SHA1CRYPTOSERVICEPROVIDER();putehash(bytes_in); sha1.dispose();字符串结果= bitconverter.tostring(bytes_out);结果=结果。replace([-,返回结果;}
,官方验证结果是可以的(忽略案例)。如果签名的URL是参数,则模型URL也必须使用参数,并且## signature H5Share H5Share(
pobull rister errer errer risrer(
p> p> p> p> p> p> pobull) wxpayapi.generatenoncestr();P>
我认为您在阅读此情况后掌握了此方法。有关更多令人兴奋的事情,请注意主机参考其他相关文章!
推荐阅读:
使用Web Pack自动更新和分析
使用H5 CACHESTEST
这几篇文章你可能也喜欢:
- 开发微信支付退款职能
- 完整的微信官方帐户开发教程1(微信官方帐户开发教程视频)
- 最适合Android开发的Linux发行版是什么?(linux android开发)
- 哪个Linux系统最适合Android开发?
- linux在嵌入式系统开发领域的广泛应用(嵌入式Linux应用场景)
本文由主机参考刊发,转载请注明:开发微信共享功能(实施微信共享功能) https://zhujicankao.com/148452.html
评论前必须登录!
注册