微信API接口,转发分享时带指定图片
JavaScript代码
- <script>
- var imgUrl = "http://www.yisky.net/indeximages/logo.gif";
- var lineLink = "http://www.yisky.net";
- var descContent = '亳州易天科技是亳州地区唯一一家获得国家软件著作权认证的,专业技术型互联网公司,专注网站制作、网站开发、微信平台架设服务电话0558-2800835';
- var shareTitle = '易天科技专业网站制作';
- var appid = '';
- function shareFriend() {
- WeixinJSBridge.invoke('sendAppMessage',{
- "appid": appid,
- "img_url": imgUrl,
- "img_width": "200",
- "img_height": "200",
- "link": lineLink,
- "desc": descContent,
- "title": shareTitle
- }, function(res) {
- })
- }
- function shareTimeline() {
- WeixinJSBridge.invoke('shareTimeline',{
- "img_url": imgUrl,
- "img_width": "200",
- "img_height": "200",
- "link": lineLink,
- "desc": descContent,
- "title": shareTitle
- }, function(res) {
- });
- }
- function shareWeibo() {
- WeixinJSBridge.invoke('shareWeibo',{
- "content": descContent,
- "url": lineLink,
- }, function(res) {
- });
- }
- // 当微信内置浏览器完成内部初始化后会触发WeixinJSBridgeReady事件。
- document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
- // 发送给好友
- WeixinJSBridge.on('menu:share:appmessage', function(argv){
- shareFriend();
- });
- // 分享到朋友圈
- WeixinJSBridge.on('menu:share:timeline', function(argv){
- shareTimeline();
- });
- // 分享到微博
- WeixinJSBridge.on('menu:share:weibo', function(argv){
- shareWeibo();
- });
- }, false);
- </script>