抖音开放平台Logo
开发者文档
控制台

H5 发布 Schema 生成示例

收藏
我的收藏

注意事项

  • 签名用的 nonce_strtimestamp 必须与 schema 中的 nonce_strtimestamp 相同。
  • 想获取用户分享结果,请通过查询视频分享结果及数据获取 share_id 将其填写到 state 字段。

JavaScript 工具包

// script 引入 <script src="https://lf3-static.bytednsdoc.com/obj/eden-cn/fljpeh7hozbf/douyin_open/cdn/dy_open_util_v0.0.6.umd.js"></script>; const schema = window.dy_open_util.serialize({ share_type: "h5", client_key: CLIENT_KEY, nonce_str: nonce_str, timestamp: timestamp, signature: signature, hashtag_list: JSON.stringify(["hashtag1", "hashtag2"]), micro_app_info: JSON.stringify({ appId: "小程序appid", appTitle: "小程序title", description: "小程序描述语", appUrl: "pages/movie/index", }), });

Python

from urllib.parse import urlencode baseUrl = "snssdk1128://openplatform/share?" param = { "client_key": CLIENT_KEY, "nonce_str": nonce_str, "timestamp": timestamp "signature": signature, "state": share_id, "share_type": "h5", "micro_app_info": json.dumps({ "appId": "小程序appId", "appTitle": "小程序title", "description": "小程序描述语", "appUrl": "pages/movie", }), "image_path": "https://sf3-cdn-tos.douyinstatic.com/obj/douyin-open-static/tiktok.open/home/d_logo.png", "share_to_publish": 1, "hashtag_list": json.dumps(["hashtag1", "hashtag2", "hashtag3", "天气不错"]) } final_url = baseUrl + urlencode(param)

Java

URIBuilder uri = new URIBuilder("snssdk1128://openplatform/share"); uri.addParameter("client_key", CLIENT_KEY); uri.addParameter("state", share_id); uri.addParameter("nonce_str", nonce_str); uri.addParameter("timestamp", timestamp); uri.addParameter("signature", signature); uri.addParameter("share_type", "h5"); uri.addParameter("image_path", "https://sf3-cdn-tos.douyinstatic.com/obj/douyin-open-static/tiktok.open/home/d_logo.png"); uri.addParameter("share_to_publish", "0"); JSONArray hashTags = new JSONArray(); hashTags.put("hashtag1"); hashTags.put("hashtag2"); hashTags.put("hashtag3"); hashTags.put("天气不错JAVA"); uri.addParameter("hashtag_list", hashTags.toString()); JSONObject microAppInfo = new JSONObject(); microAppInfo.put("appId", "小程序appId"); microAppInfo.put("appTitle", "小程序title"); microAppInfo.put("description", "小程序描述语"); microAppInfo.put("appUrl", "pages/movie/index"); uri.addParameter("micro_app_info", microAppInfo.toString()); String url = uri.build().toString();

JavaScript

const url = new URL("snssdk1128://openplatform/share"); var query = url.searchParams; query.append("client_key", CLIENT_KEY); query.append("state", share_id); query.append("nonce_str", nonce_str); query.append("timestamp", timestamp); query.append("signature", signature); query.append("share_type", "h5"); query.append( "image_path", "https://sf3-cdn-tos.douyinstatic.com/obj/douyin-open-static/tiktok.open/home/d_logo.png" ); query.append("share_to_publish", "0"); const hashTags = ["hashtag1", "hashtag2", "hashtag3", "天气不错"]; query.append("hashtag_list", JSON.stringify(hashTags)); query.append( "micro_app_info", JSON.stringify({ appId: "小程序appid", appTitle: "小程序title", description: "小程序描述语", appUrl: "pages/movie/index", }) );

该文档是否有帮助?