
README.md document for execution. You can also continue integrating this into your own project by following the subsequent documentation.


/loginTCCC will be used in the following text to explain the developed interface in this step.// A version of `tencentcloud-sdk-nodejs` that is 4.0.3 or higher.const tencentcloud = require('tencentcloud-sdk-nodejs');const express = require('express');const app = express();const CccClient = tencentcloud.ccc.v20200210.Client;app.use('/loginTCCC', (req, res) => {const clientConfig = {// Secret retrieval address: https://console.tencentcloud.tencent.com/cam/capicredential: {secretId: 'SecretId',secretKey: 'SecretKey'},region: 'ap-singapore',profile: {httpProfile: {endpoint: 'ccc.tencentcloudapi.com'}}};const client = new CccClient(clientConfig);const params = {SdkAppId: 1600000000, // Please replace with your own SdkAppIdSeatUserId: 'xxx@qq.com' // Replace with the agent account};client.CreateSDKLoginToken(params).then((data) => {res.send({SdkURL: data.SdkURL})},(err) => {console.error('error', err);res.status(500);});})
/loginTCCC interface, which was achieved in the second step, to obtain the SdkURL.function injectTcccWebSDK(SdkURL) {if (window.tccc) {console.warn('SDK has already been initialized. Please confirm if it is being initialized repeatedly');return;}return new Promise((resolve, reject) => {const script = document.createElement('script');script.setAttribute('crossorigin', 'anonymous');// The DomId that needs to be rendered// To ensure a complete workspace UI, the rendering Dom has a minimum height of 480px and a minimum width of 760px// script.dataset.renderDomId = "renderDom";script.src = SdkURL;document.body.appendChild(script);script.addEventListener('load', () => {// JS SDK file is loaded successfully. You can now use the global variable "tccc"window.tccc.on(window.tccc.events.ready, () => {/*** Once the TCCC SDK is successfully initialized, you can start using functionalities such as event listening and more.* Caution: Ensure that the SDK is initialized only once* */resolve('Successfully initialized')});window.tccc.on(window.tccc.events.tokenExpired, ({message}) => {console.error('Initialization failed', message)reject(message)})})})}// Request the interface implement in the second step /loginTCCC// Caution: The following is merely code illustration, not advisable to execute directlyfetch('/loginTCCC').then(res => res.json()).then((res) => {const SdkURL = res.SdkURL; // Ensure SdkURL is always returned through request, otherwise unpredictable errors may occur!return injectTcccWebSdk(SdkURL);}).catch((error) => {// Initialization failedconsole.error(error);})
Feedback