How to use Vuforia Web Services API with JavaScript? - javascript

I've trying several things but nothing is really working. There are some examples in Vuforia Web Services API documentation using PHP but there's nothing with JavaScript.

It seems there's no Javascript API available for VWS. Even if it were, you will probably not be able to call it from web browser because of Cross domain policies.
That said, you can write your own back-end client in JS or run one of the samples in (Java/PHP/Python) in the server and expose all the methods as REST end-points.
VWS seems to be plain old REST services, which can be called from any language.
Only hurdle in writing your own simple client is to calculate signature for the requests, here's the logic to calculate signature from the documenation
Ref: https://library.vuforia.com/content/vuforia-library/en/articles/Training/Using-the-VWS-API.html
After you have the function for signature you will have to convert sample requests from the download for selected language to Javascript
These are the files in sample that I downloaded for Java, (https://github.com/christolb/MobEmbedded/tree/master/Pradeep/VWS%20Sample, it's uploaded by someone else on Github, I'm not adding it here myself, as I'm unsure of the licensing restrictions)
DeleteTarget.java
GetAllTargets.java
GetTarget.java
PostNewTarget.java
SignatureBuilder.java
Summary.java
TargetState.java
TargetStatusListener.java
TargetStatusPoller.java
UpdateTarget.java

Related

External API access with Ruby blocked by CloudFlare

I am trying to access the HaveIBeenPwned web API for breached sites and emails, but I am being blocked by cloudflare's anti-DDoS protection. I've found that there are ways to get around this with Python and JavaScript, but I haven't been successful with my React/Rails app.
This post has the following quote: "Currently, they check if the client supports JavaScript, which can be spoofed." I haven't been able to find any other documentation of this behavior.
I need this information in the backend, so calling HIBP from the frontend is not ideal. Any idea how to hit the API from Rails?
If they want it to be used on frontend only, using it on backend can be tricky. You will need to create your own wrapper with, for example, puppeteer. And from Rails side execute command that will do some work in background. But keep in mind, it doesn't work very fast (can take up to 5 seconds per request), and it will block your Rails process.
I would start with single node.js app that will accept command-line parameters. Ruby isn't very good at advanced web scraping, so there are no any gentle solutions. Also, keep in mind that you don't have any guarantees. One day it can just stop working.

Google API Client Libraries API Key Security and Javascript

In the Google API Client Libraries sample documentation it has the API key directly inside the code as shown here
https://developers.google.com/api-client-library/javascript/samples/samples.
However, in the best practices documentation it says specifically to not do that. I have been pondering ways to successfully separate and secure the API key, but it adds significant overhead by essentially requiring a server side proxy that performs the api call and returns the response. This is all well and good until you also want to include pagination tokens with the response to allow quicker responses by not requesting the whole response. Does anyone have any ideas for securing the API Key in javascript?

Adobe Captivate: Using GET/POST for Server Side Calculation in SCORM Module

Is it possible for Captivate 6 to exchange data with a PHP script via POST/GET while maintaining our ability to package our module into SCORM? Our module needs to exchange data from the user and send to our server farm for some computational-heavy calculations, which are then used in the module to modify the information displayed to the user. This is independent of the SCORM functionality.
I have seen a few examples where people have set the reporting options of their module to "email" (as opposed to SCORM) and then modified the email reporting javascript functions provided by Captivate to send data via GET/POST using XMLHttpRequest. In our case this will not work because I still need to do my reporting via SCORM. However, I also need to access some server side resources on our web server to drive the Captivate presentation.
Any ideas?
You can get/set variables in Captivate using JavaScript.
Extract data from Captivate using JavaScript (my open-source CaptivateController utility is designed to make this easy).
Pass the data to your PHP page using xmlhttprequest (aka AJAX). *
Send any return values to Captivate using JavaScript (again, the CaptivateController makes this easy).
Then do whatever you wish with the data inside Captivate.
This is all independent of SCORM. Bear in mind that a true SCORM package does not rely on an external PHP script, but there is no technical reason why it wouldn't work.
* Watch out for cross-domain scripting issues when trying to pass the data from your course to your PHP file and back. If you run into problems, search StackOverflow -- there are plenty of StackOverflow posts covering cross-domain scripting issues.

OAuth, javascript and many URI's

I'm trying to make a program that can be hosted by many peoples, like an app.
The app use a REST API, so I must authenticate with Oauth,
and because anyone should be able to host the program, the redirect URI cannot be static.
Further, I don't want to use any server-side processing, which means only javascript for me.
Is it even possible to make a secure and working solution with non-static redirect URI,
and only using javascript, to work in a normal webbrowser?
So you use the information provided in the request to your app to indicate the URL for your app. For instance, if the request came to http://example.com/path/to/app and you knew in your app that /to/app was part of your routing infrastructure, then the path to your app is http://example.com/path/.
That is how I would determine it, using a serverside language.
Using a javascript library, which would be loaded from the server, I would either determine it like the above, or I would just hard code it on the generation of the javascript file (when you tell people where to download the javascript, it can use a form that requires their web address first).

Call a SOAP Service using JavaScript

As the title suggests, I'm trying to figure out how to call a soap service using JavaScript. The SOAP Service is being run on Tomcat on my local machine. Along with accessing the SOAP service, I can also download/access/read the WSDL very easily.
I've been hitting my head against the wall for days now with this problem. While researching, I'm come across short examples, but none are comprehensive and detail how to accomplish this from start to end. That, or I've found a solution but it only works for IE or Mozilla.
Any ideas how to call a SOAP web service using Javascript (on major browsers)? Thanks!
(PS: I'm also using jquery. So if you want to accomplish this using some slick jquery tool, please feel free to suggest it)
SOAP is just XML so it should be possible to do this, however I'm not aware of any existing SOAP Clients written in JS
A more common method would probably be:
JavaScript initiates an XHR object which calls to a server-side AJAX helper using either GET/POST parameters, or a JSON encoded object
AJAX helper makes the call to either a Database or Web Service, as appropriate, and outputs required data object(s) as either JSON or XML
JavaScript parses response body (JSON or XML) and takes required action using specified data.
This has a couple of advantages over trying to call WebServices directly from JavaScript:
SOAP XML can be quite complex, which means more data to transfer to and from the client, which may be a slow connection. JSON in particular, but also an XML schema that just has the required data would be a much more economical on data usage
If the WebService requires any kind of authentication the authentication details will be exposed to all visitors.
Web Services are generally used for to standardise communications between separate systems, rather than for communication between the front and back end components of the same Application/Site.

Categories