微信API接口,轉(zhuǎn)發(fā)分享時(shí)帶指定圖片
JavaScript代碼
- <script>
- var imgUrl = "http://hou-g.com/indeximages/logo.gif";
- var lineLink = "http://hou-g.com";
- var descContent = '亳州易天科技是亳州地區(qū)唯一一家獲得國(guó)家軟件著作權(quán)認(rèn)證的,專業(yè)技術(shù)型互聯(lián)網(wǎng)公司,專注網(wǎng)站制作、網(wǎng)站開(kāi)發(fā)、微信平臺(tái)架設(shè)服務(wù)電話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) {
- });
- }
- // 當(dāng)微信內(nèi)置瀏覽器完成內(nèi)部初始化后會(huì)觸發(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>