敬告:此 DEMO 演示为开放测试页面,仅用于开发者快速测试体验应用功能,请严格遵守开发者协议,了解更多。
♦ JS-SDK 引用方式:
♦ 普通网页 script 方式加载:下载最新版 jsBridge-v20241118.zip,请在页面上调用 jsBridge 接口之前引用 jsbridge-mini.js 库;
♦ js module 方式引用:npm install ym-jsbridge 具体请参考 npm package
jsBridge.fbShare.shareLink({ //其他公共参数 //... //话题 the ShareHashtag for this content hashtag : "#UkraineCrisis", //链接 the URL for the content being shared contentUrl: "https://m.baidu.com", //引用 the quote to display for this link quote : "Connect on a global scale." }, function(succ, data) { if (data.result == "success") { alert("成功:" + data.postId); } else if (data.result == "cancel") { alert("取消"); } else if (data.result == "error") { alert("错误:" + data.message); } else { alert(JSON.stringify(data)); } }); /* 所有分享接口都支持的公共参数 { //链接 the URL for the content being shared //可选,字符串 contentUrl: "https://m.baidu.com", //标记人 the list of Ids for taggable people to tag with this content //可选,字符串数组 peopleIds : [], //位置 the Id for a place to tag with this content //可选,字符串 placeId : "", //页面 the Id of the Facebook page this share is associated with //可选,字符串 pageId : "", //the value to be added to the referrer URL when a person follows a link from this shared content on feed //可选,字符串 ref : "", //话题 the ShareHashtag for this content //可选,#号开头的字符串 hashtag : "" } */
jsBridge.fbShare.sharePhoto({ //可选的公共参数 //... //照片数组 photos: [ { url : "https://i.yimenyun.net/sys/1.jpg", caption: "图一的说明", //照片是用户还是应用生成的 whether the photo represented by this object was generated by the user or by the application //布尔类型 userGenerated: false }, { url : "https://i.yimenyun.net/sys/2.jpg", caption: "图二的说明", userGenerated: false }, { url : "https://i.yimenyun.net/sys/3.jpg", caption: "图三的说明", userGenerated: false } ] }, function(succ, data) { if (data.result == "success") { alert("成功:" + data.postId); } else if (data.result == "cancel") { alert("取消"); } else if (data.result == "error") { alert("错误:" + data.message); } else { alert(JSON.stringify(data)); } });
jsBridge.fbShare.shareVideo({ //可选的公共参数 //... //描述 contentDescription: "the description of the video", //标题 contentTitle: "the title to display for this video", //预览图 the photo to be used as a preview for the video previewPhoto: { url : "https://i.yimenyun.net/sys/1.jpg", caption: "图片说明", userGenerated: false }, //视频链接 videoUrl: "https://flv4mp4.people.com.cn/videofile7/pvmsvideo/2022/2/25/GuiZhouPinDao-TuMin_5905588433c0cefc445c910f6e7f772d.MP4" }, function(succ, data) { if (data.result == "success") { alert("成功:" + data.postId); } else if (data.result == "cancel") { alert("取消"); } else if (data.result == "error") { alert("错误:" + data.message); } else { alert(JSON.stringify(data)); } });
jsBridge.fbShare.shareMedia({ //可选的公共参数 //... //可选,照片数组 photos: [ { url : "https://i.yimenyun.net/sys/1.jpg", caption: "图一的说明", userGenerated: false }, { url : "https://i.yimenyun.net/sys/2.jpg", caption: "图二的说明", userGenerated: false } ], //可选,视频数组 videos: [ "https://flv4mp4.people.com.cn/videofile7/pvmsvideo/2022/2/25/GuiZhouPinDao-TuMin_5905588433c0cefc445c910f6e7f772d.MP4", "https://flv3.people.com.cn/dev1/mvideo/vodfiles/2020/06/24/da474a070de6618985811f72a523ba55_c.mp4" ] }, function(succ, data) { if (data.result == "success") { alert("成功:" + data.postId); } else if (data.result == "cancel") { alert("取消"); } else if (data.result == "error") { alert("错误:" + data.message); } else { alert(JSON.stringify(data)); } });