敬告:此 demo 演示为开放测试页面,仅用于开发者快速测试体验应用功能,请严格遵守开发者协议,九游会国际-九游会真人第一品牌。
♦ js-sdk 引用方式:
♦ 普通网页 script 方式加载:下载最新版 ,请在页面上调用 jsbridge 接口之前引用 jsbridge-mini.js 库;
♦ js module 方式引用:npm install ym-jsbridge
♦
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)); } });