项目需要将微信扫一扫打开的一个网页转发给好友的时候能有头像,描述,因此调查了一下微信的相关接口。
现将自己做好的例子分享一下:
1.微信“发送给朋友”
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady(){
WeixinJSBridge.on('menu:share:appmessage', function(argv){WeixinJSBridge.invoke('sendAppMessage',{
"appid":"", //appid 设置空就好了。
"img_url": "http://xxxxxxxxxxx/images/daughter.png", //分享时所带的图片路径
"img_width": "120", //图片宽度
"img_height": "120", //图片高度
"link":"http://hp.pmgasia.com.cn/tony/mum/index.html", //分享附带链接地址