微信API接口,轉發(fā)分享時帶指定圖片
JavaScript代碼
- <script>
- var imgUrl = "http://www.m.002bubu.com/indeximages/logo.gif";
- var lineLink = "http://www.m.002bubu.com";
- var descContent = '亳州易天科技是亳州地區(qū)唯一一家獲得國家軟件著作權認證的,專業(yè)技術型互聯(lián)網(wǎng)公司,專注網(wǎng)站制作、網(wǎng)站開發(fā)、微信平臺架設服務電話0558-2800835';
- var shareTitle = '易天科技專業(yè)網(wǎng)站制作';
- 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) {
- });
- }
- // 當微信內(nèi)置瀏覽器完成內(nèi)部初始化后會觸發(fā)WeixinJSBridgeReady事件。
- document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
- // 發(fā)送給好友
- 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>