Reputation: 307
Trying to figure out how to use the MS Translator API to use the MS Translator but running into problems.
I don't have the ability to serve up a Node, PHP or other server to securely provide the ClientID or ClientSecret at this time so I'm trying to do it simply with straight HTML and Javascript for now.
I'm trying to use this AJAX as recommended by MS API but I believe this is looking for the server to provide the authentication. Looking for help to figure out how to right this with HTML/JS without the server side authentication. Thanks!
function translate() {
var from = "en", to = "es", text = "hello world";
var s = document.createElement("script");
s.src = "http://api.microsofttranslator.com/V2/Ajax.svc/Translate" +
"?appId=" + settings.appID +
"&from=" + encodeURIComponent(from) +
"&to=" + encodeURIComponent(to) +
"&text=" + encodeURIComponent(text) +
"&oncomplete=mycallback";
document.body.appendChild(s);
}
function mycallback(response) {
alert(response);
}
Upvotes: 1
Views: 1447
Reputation: 104
Try using appId=8B841CA7C1A03443682C52AD07B7775A7BD5B3AA
This works fine for me, I found that on the other thread. Sorry if this is not what you are looking for. I have to admit the authentication is the difficult part, I even tried using the script found at the MDSN page on translate, http://msdn.microsoft.com/en-us/library/ff512406.aspx
I couldn't comment with my 26 rep points, so I am writing here as my answer. Thanks.
Upvotes: 0