微软翻译api的使用介绍和注意事项
?google翻譯api已經(jīng)收費(fèi)了,而微軟翻譯api目前是免費(fèi)的,支持幾種不同的方式訪問,如果感興趣可以自己封裝下協(xié)議處理。官方介紹:
http://msdn.microsoft.com/en-us/library/hh454950.aspx。
這里介紹一下java下的使用。Java下使用微軟翻譯api可以直接使用一個(gè)開源的sdk,http://code.google.com/p/microsoft-translator-java-api/。
?
?一、首先去http://code.google.com/p/microsoft-translator-java-api/,下載相關(guān)jar文件,這里有對(duì)微軟翻譯api的詳細(xì)使用有作詳細(xì)介紹。?
?? 二,去申請(qǐng)key,進(jìn)入http://www.bing.com/developers/createapp.aspx,填寫相關(guān)的你的應(yīng)用信息就行了。就會(huì)有下面的圖片中顯示的key,中的Application ID就是key。?
? 三、下面給個(gè)實(shí)例:?
Java代碼??
?
四、運(yùn)行結(jié)果:Property?
?
這里說下可能出現(xiàn)的問題:
1、android下要用microsoft-translator-java-api-0.6-jar-with-dependencies.jar,否則運(yùn)行時(shí)可能會(huì)報(bào)錯(cuò)android java.lang.NoClassDefFoundError: org.json.simple.JSONValue。
2、使用過程中出現(xiàn)錯(cuò)誤:TranslateApiException: Cannot find an Azure Market Place Translator Subscription associated with the request credentials,則需要到網(wǎng)址上先訂閱translate api的免費(fèi)流量,操作如下:
Make sure you login to azure market place ?click on data and select Microsoft Translator. Now click on 2000000 c/moth @ $0 update option. Now I think this error will go away. Try following link also. This is the link where I signed up for 2000000 c/month offer. I was facing the same problem but when I updated my account through following link, this error went away.(參考:http://social.msdn.microsoft.com/Forums/zh-CN/microsofttranslator/thread/1eeb0066-553f-4523-9a1b-0976e4205bb2)
轉(zhuǎn)載于:https://www.cnblogs.com/brainy/archive/2012/05/24/2516487.html
總結(jié)
以上是生活随笔為你收集整理的微软翻译api的使用介绍和注意事项的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: socket编程资料-网络收集
- 下一篇: ios启动画面