我已经使用 java 和 java 脚本创建了 cisco webex 小部件。我已在 Cisco Webex Developers 网站上注册,并为来宾用户创建了一个应用程序。
代码工作正常。
下面显示的代码正确生成令牌。除了符号之外,还创建了 json 标头和有效负载。
public class CiscoWebexFacade {
private static Log _log = LogFactoryUtil.getLog(CiscoWebexFacade.class);
private CiscoWebexJsonEncode ciscoWebexJsonEncode = Singleton.getInstance(CiscoWebexJsonEncode.class);
public String getToken() {
String signed = null;
//Date currentTime = new Date();
//int expire = (int) (currentTime.getTime() + 24*3600*1000L);
//JSON
String header = ciscoWebexJsonEncode.getJsonHeader();
JSONObject payload = ciscoWebexJsonEncode.getJsonPayload(CiscoWebexPortletKeys.SUBJECT, CiscoWebexPortletKeys.NAME,
CiscoWebexPortletKeys.ISSUER_ID);
byte[] headerBytes = header.toString().getBytes(StandardCharsets.UTF_8);
byte[] payloadBytes = payload.toString().getBytes(StandardCharsets.UTF_8);
//byte[] secretBytes = CiscoWebexPortletKeys.SHARED_SECRET.toString().getBytes(StandardCharsets.UTF_8);
byte[] secretBytes = Base64.getDecoder().decode(CiscoWebexPortletKeys.SHARED_SECRET);
String encodedData = Base64.getUrlEncoder().encodeToString(headerBytes) + '.' +
Base64.getUrlEncoder().withoutPadding().encodeToString(payloadBytes);
//Firma
try {
Mac sha256Hmac = Mac.getInstance(CiscoWebexPortletKeys.HMAC_SHA_256);
SecretKeySpec secretKeySpec = new SecretKeySpec(secretBytes, CiscoWebexPortletKeys.HMAC_SHA_256);
sha256Hmac.init(secretKeySpec);
byte[] signedBytes = sha256Hmac.doFinal(encodedData.toString().getBytes(StandardCharsets.UTF_8));
signed = Base64.getUrlEncoder().withoutPadding().encodeToString(signedBytes);
} catch (InvalidKeyException | NoSuchAlgorithmException e) {
e.printStackTrace();
}
//Token
String token = encodedData + '.' + signed;
_log.info("TOKEN: " + token);
return token;
}
}
下面是控制器类
public class CiscoWebexPortlet extends MVCPortlet {
private CiscoWebexFacade ciscoWebexFacade = Singleton.getInstance(CiscoWebexFacade.class);
@Override
public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
String token = ciscoWebexFacade.getToken();
renderRequest.setAttribute(CiscoWebexPortletKeys.TOKEN, token);
super.render(renderRequest, renderResponse);
}
}
在视图中,javascript 代码使用访客令牌和目标电子邮件生成 Webex 小部件。
<div id="cisco-webex">
<div id="my-webex-widget"></div>
</div>
<script>
<script src="https://code.s4d.io/widget-space/production/bundle.js"></script>
<link rel="stylesheet" href="https://code.s4d.io/widget-space/production/main.css">
var widgetEl = document.getElementById('my-webex-widget');
// Init a new widget
webex.widget(widgetEl).spaceWidget({
guestToken: '${token}',
destinationId: 'email_user@email.com', //email destination
destinationType: 'email',
spaceActivities: {"files": true, "meet": true, "message": true, "people": true},
initialActivity: 'message',
secondaryActivitiesFullWidth: false,
composerActions: {"files": true, "meet": true, "message": true, "people": true},
disablePresence: false
});
</script>
下面是网页上的嵌入式小部件。
我想将 cisco webex 流式直播嵌入网站(不是 YouTube)。我查看了 Cisco Webex 文档,但找不到。有谁知道怎么做?或者有人可以给我一些建议吗?
谢谢!
问候!