AI助手支持GPT4.0
微信分享,无法调起微信分享?
如题,分享老是不成功,各种方法已尝试,请问各位怎么解决?
1,已在微信公众号配置了安全域名
2,加载js jweixin-1.6.0.js ; 页面初始化调用了config,debug开启也弹出了ok
3,点击分享时候,旧版本onMenuShareAppMessage无反应;新版本updateAppMessageShareData直接进入success方法,并没有调用微信分享;
4代码如下:
$.ajax({
type: "GET",
url: hostUrl + "/api/foot/share",
data:{url : location.href.split("#")[0]},
success: function(data){
wx.config({
debug : true,
appId : data.appId,// 必填,公众号的唯一标识
timestamp : data.timestamp,// 必填,生成签名的时间戳
nonceStr : data.nonceStr,// 必填,生成签名的随机串
signature : data.signature.toLowerCase(),// 必填,签名
jsApiList : [
// 'updateAppMessageShareData',//新
'onMenuShareAppMessage',//旧
'onMenuShareTimeline' //旧
] // 必填,需要使用的JS接口列表
});
share();
}
});
function share(){
wx.ready(function(){
var fx = {
title : document.title, // 分享标题
desc : document.title, // 分享描述
link : location.href.split("#")[0], // 分享链接
imgUrl :"http://fxxxxxx/p51_S4ICON3_TIMELESS_2ND_ENGLAND.png", // 分享图标
type : 'link', // 分享类型,music、video或link,不填默认为link
success : function(e) {
// 用户确认分享后执行的回调函数
alert("分享成功:"+JSON.stringify(e));
},
cancel : function() {
// 用户取消分享后执行的回调函数
alert("取消分享");
}
,fail:function(res){
alert("失败:"+JSON.stringify(res));
console.log(res);
}
};
//分享给朋友
wx.onMenuShareAppMessage(fx);
// wx.onMenuShareTimeline(fx);
});
}
If the topic is not shared successfully, various ways have been tried. How do you solve it? 1, the security domain name 2 has been installed in WeChat official account, loading JS jweixin-1.6.0.js. Config is called for page initialization, and OK 3 pops up when debug is opened. 3. When you click share, the old version of onmenushareappmessage doesn't respond; the new version of updateappmessage sharedata directly enters the success method without calling wechat sharing; 4 code is as follows: $. Ajax ({type: "get", URL: hosturl + "/ API / foot / share", data: {URL: location.href.split ("#")[0]}, success: function(data){ wx.config ({ debug : true, appId : data.appId / / required, the only indication of official account number timestamp: data.timestamp , / / required. The time stamp for generating the signature, noncestr: data.nonceStr , / / required, generate a random string signature: data.signature.toLowerCase (), / / required, signature jsapilist: [/'updateappmessage sharedata ', //New 'onmenushareappmessage' / / old 'onmenusharetimeline' / / old] / / required, list of JS interfaces to be used}); share();;}}); function share (){ wx.ready (function(){ var fx = { title : document.title , / / share Title desc: document.title , / / share description link: location.href.split ("ා) [0], / / share link imgurl:“ http://fxxxxxx/p51_ S4ICON3_ TIMELESS_ 2ND_ ENGLAND.png ", / / the sharing icon type is' link '/ / the sharing type is music, video or link. If it is not filled in, the default value is link success: function (E) {/ / the callback function" share succeeded "will be executed after the user confirms the sharing+ JSON.stringify (e) );}, cancel: function() {/ / the callback function "alert" executed after the user cancels sharing;}, fail:function (RES) {alert+ JSON.stringify (res)); console.log (RES);}}; / / share with friends wx.onMenuShareAppMessage (fx); // wx.onMenuShareTimeline (fx); }); }
你是希望直接拉起分享选择好友的界面吗?这个是调不起来的,这两个api都是更新分享的内容,不是调起分享。更新分享内容后,用户在点击分享的时候内容才会是你配置的内容。