微信API接口,轉發分享時帶指定圖片
JavaScript代碼
- <script>
- var imgUrl = "http://m.heaithplan.com/indeximages/logo.gif";
- var lineLink = "http://m.heaithplan.com";
- 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>