链接制作软件链接⾃定义分享功能,链接⾃定义⼯具(标题,图⽚,内容,链接⾃定义分享)
⽤打开⼀个⽹页,选择右上⾓的“发送给朋友”后,收到的消息是这样的:
⽽为了推⼴效果,我们更希望能⾃定义标题、描述和图⽚,效果如下图:
下⾯介绍下怎样来实现这个功能
⽅案实现
⽅法1:使⽤飞哥⼯具箱
1、进⼊官⽹链接
www.fgcq39
2、需准备材料
准备链接+⾃定义的标题+⾃定义的内容+logo
3、
⽅法2:对接飞哥⼯具箱接⼝
1、需准备材料
①分享标题+描述+logo
②⾃⼰的分享域名
③对接接⼝⾃动⽣成
⽅法3:对接SDK
JS-SDK是公众平台⾯向⽹页开发者提供的基于内的⽹页开发⼯具包。可参考JS-SDK说明⽂档。
具体步骤:
1、准备⼀个备案的域名和空间,绑定域名到该空间去。以及⼀个认证过的,
2、登录公众平台,进⼊“设置”的功能设置⾥⾯填写js接⼝安全域名,这个要填写的是你浏览器要打开的域名地址,不能添加IP 地址。
3、引⼊js⽂件,在需要调⽤js接⼝的页⾯接⼊JS⽂件。
res.wx.qq/open/js/jweixin-1.2.0.js
4、通过config接⼝注⼊权限并验证配置(这⼀步算是整个步骤中最关键的⼀步,必须正确的配置信息才可以进⾏调⽤JS-SDK。)
debug: true, // 开启调试模式,调⽤的所有api的返回值会在客户端alert出来,若要查看传⼊的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
appId: '', // 必填,的唯⼀标识
timestamp: , // 必填,⽣成签名的时间戳
nonceStr: '', // 必填,⽣成签名的随机串
signature: '',// 必填,签名,见附录1
});
详细接⼊代码
+ (currentLink.indexOf("?") > -1 ? ("&u=" + "${u!}" + "&t=" + "${t!}" + "&o=" + "${o!}" + "&s=" + "${s!}") : ("?u=" + "${u!}" + "&t=" + "${t!}" + "&o=" + "${o!}" + "&s=" + "${s!}")); shareLink = shareLink + (shareLink.indexOf("?") > -1 ? ("&city=" + "深圳") : ("?city=" + "深圳"));
var shareImgUrl = "${IMGPATH!}/images/banner2.png";
var shareGid = "";
//分享给朋友
title: shareTitle,
desc: shareDesc,
link: shareLink,
imgUrl: shareImgUrl,
success: function (res) {
shared(shareLink, "friend", shareGid);
},
fail: function (res) {
alert(JSON.stringify(res));
}
});
//分享到朋友圈
title: shareTitle,
desc: shareDesc,
link: shareLink,
imgUrl: shareImgUrl,
success: function (res) {
shared(shareLink, "Timeline", shareGid);
},
fail: function (res) {
alert(JSON.stringify(res));
}
});
//分享到QQ
title: shareTitle,
desc: shareDesc,
link: shareLink,
imgUrl: shareImgUrl,
success: function (res) {
shared(shareLink, "QQ", shareGid);
},
fail: function (res) {
alert(JSON.stringify(res));
}
});
//分享到腾讯QQ
title: shareTitle,
desc: shareDesc,
link: shareLink,
imgUrl: shareImgUrl,
success: function (res) {
shared(shareLink, "Weibo", shareGid);
},
fail: function (res) {
alert(JSON.stringify(res));
}
});
//分享到QZone
title: shareTitle,
desc: shareDesc,
link: shareLink,
imgUrl: shareImgUrl,
success: function (res) {
shared(shareLink, "QZone", shareGid);
},
fail: function (res) {
alert(JSON.stringify(res));
}
});
});
function shared(url, type, gid){
var rUrl = basePath + "/share/add?type=" + type + "&url=" + encodeURI(url);
if(!!gid) {
rUrl += "&gid=" + gid;
}
type: "GET",
url: rUrl,
dataType: "json",
success: function(rs){
//alert("分享成功");
}
});
}
" _ue_custom_node_="true">
+ (currentLink.indexOf("?") > -1 ? ("&u="+ "${u!}"+ "&t="+ "${t!}"+ "&o="+ "${o!}"+ "&s="+ "${s!}") : ("?u="+ "${u!}"+ "&t="+ "${t!}"+ "&o="+ "${o!}"+ "&s="+ "${s!}")); shareLink = shareLink + (shareLink.indexOf("?") > -1 ? ("&city="+ "深圳") : ("?city="+ "深圳"));
var shareImgUrl = "${IMGPATH!}/images/banner2.png";
var shareGid = "";
//分享给朋友
title: shareTitle,
desc: shareDesc,
link: shareLink,
imgUrl: shareImgUrl,
success: function(res) {
shared(shareLink, "friend", shareGid);
},
fail: function(res) {
alert(JSON.stringify(res));
}
});
//分享到朋友圈
title: shareTitle,
desc: shareDesc,
link: shareLink,
imgUrl: shareImgUrl,
success: function(res) {
shared(shareLink, "Timeline", shareGid);
},
fail: function(res) {
alert(JSON.stringify(res));
}
图片链接怎么生成});
//分享到QQ
title: shareTitle,
desc: shareDesc,
link: shareLink,
imgUrl: shareImgUrl,
success: function(res) {
shared(shareLink, "QQ", shareGid);
},
fail: function(res) {
alert(JSON.stringify(res));
}
});
//分享到腾讯QQ
title: shareTitle,
desc: shareDesc,
link: shareLink,
imgUrl: shareImgUrl,
success: function(res) {
shared(shareLink, "Weibo", shareGid);
},
fail: function(res) {
alert(JSON.stringify(res));
}
});
/
/分享到QZone
title: shareTitle,
desc: shareDesc,
link: shareLink,
imgUrl: shareImgUrl,
success: function(res) {
shared(shareLink, "QZone", shareGid);
},
fail: function(res) {
alert(JSON.stringify(res));
});
});
function shared(url, type, gid){
var rUrl = basePath + "/share/add?type="+ type + "&url="+ encodeURI(url); if(!!gid) {
rUrl += "&gid="+ gid;
}
$.ajax({
type: "GET",
url: rUrl,
dataType: "json",
success: function(rs){
/
/alert("分享成功");
}
});
}
" _ue_custom_node_="true">
好了,先写这些,有不明⽩的可以关注私信我
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论