javascript lcom-techblog:LTI JavaScript示例(https://medium.com/lcom-techblog/simple-lti-tool-consumer-

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript lcom-techblog:LTI JavaScript示例(https://medium.com/lcom-techblog/simple-lti-tool-consumer-相关的知识,希望对你有一定的参考价值。

var oauth = require('oauth-sign');
var action = 'https://lti.tools/saltire/tp';
var method = 'POST';
var timestamp = Math.round(Date.now() / 1000);
var params = {
    // LTI Required Parameters
    lti_message_type: 'basic-lti-launch-request',
    lti_version: 'LTI-1p0',
    resource_link_id: 'resourceLinkId',
    // OAuth 1.0a Required Parameters
    oauth_consumer_key: 'jisc.ac.uk',
    oauth_nonce: btoa(timestamp),
    oauth_signature_method: 'HMAC-SHA1',
    oauth_timestamp: timestamp,
    oauth_version: '1.0'
};
var signature = oauth.hmacsign(method, action, params, 'secret');
params.oauth_signature = signature;
var form = document.querySelector("#ltiForm");
form.action = action;
form.method = method;
for (var name in params) {
    var node = document.createElement("input");
    node.name = name;
    node.type = 'hidden';
    node.value = params[name];
    form.appendChild(node);
}
var output = document.querySelector("code");
output.textContent = JSON.stringify(params, null, 2);
console.log(form);
var meta = document.querySelector("body > script");
console.log(meta);

以上是关于javascript lcom-techblog:LTI JavaScript示例(https://medium.com/lcom-techblog/simple-lti-tool-consumer-的主要内容,如果未能解决你的问题,请参考以下文章

JavaScript介绍

javascript的题。

javascript JavaScript isset()等效: - JavaScript

JavaScript 使用JavaScript更改CSS(JavaScript)

JavaScript之基础-1 JavaScript(概述基础语法)

前端基础-JavaScript的基本概述和语法