Node
The following code example is written in Node.js:
- var express = require("express");
- var http = require("http");
- var app = express();
- var LogiAppURL = "http://<yourServer>/<LogiApp>";
- var UserName = "Bob";
- var Roles = "Admin";
- var Rights = "Manager";
- var MessageBack = "";
- /* create an app to listen on the port # specified in the app arg */
- app.get("*", function(req, resM) {
- /* send the SecureKey request */
- http.get(LogiAppURL + "/rdTemplate/rdGetSecureKey.aspx?"Username=" + UserName + "&Roles=" + Roles + "&Rights=" + Rights + "&ClientBrowserAddress=" + resM.connection.remoteAddress, function(res) {
- /* when the key is returned */
- res.on("data", function(chunk) {
- MessageBack = chunk;
- /* send a response to the browser (using our Embedded Report API in this example) */
- resM.send("<p style=\"font-size:20px;text-align:center;\" > This is a node page </p> <div id=\"divNd\" data-autoSizing=\"all\" data-applicationUrl=\"' + LogiAppURL + '\" data-report=\"Default\" data-linkParams=\"{'rdSecurekey' : '" + MessageBack + "'}\" > </div> <script src=\"' + LogiAppURL + '/rdTemplate/rdEmbedApi/rdEmbed.js\" type=\"text/Javascript\"></script>" );
- });
- /* server-side error logging */
- }).on('error', function(e) {
- console.log("Got error: " + e.message);
- });
- });
- console.log("Web application opened.");
- app.listen(1337);