Skip to content

Instantly share code, notes, and snippets.

@joepie91
Forked from dsauerbrun/.js
Last active August 27, 2015 20:50
Show Gist options
  • Save joepie91/fe2dade86e7e3a2ce2b6 to your computer and use it in GitHub Desktop.
Save joepie91/fe2dade86e7e3a2ce2b6 to your computer and use it in GitHub Desktop.
function bingTranslate(message,originLang,destLang,accessToken){
Promise.try(function(){
accessToken.then(function(bingToken){
options = {
headers:{
'Authorization': "Bearer "+accessToken
}
};
queryString="text="+encodeURIComponent(message)+"&from="+originLang+"&to="+destLang+"&contentType=text%2Fplain";
return bhttp.get("http://api.microsofttranslator.com/V2/Http.svc/Translate?"+queryString,options).then(function(data){
return xml.parseBuffer(data.body).childs[0];
})
})
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment