微软翻译api的使用介绍和注意事项
?google翻譯api已經收費了,而微軟翻譯api目前是免費的,支持幾種不同的方式訪問,如果感興趣可以自己封裝下協議處理。官方介紹:
http://msdn.microsoft.com/en-us/library/hh454950.aspx。
這里介紹一下java下的使用。Java下使用微軟翻譯api可以直接使用一個開源的sdk,http://code.google.com/p/microsoft-translator-java-api/。
?
?一、首先去http://code.google.com/p/microsoft-translator-java-api/,下載相關jar文件,這里有對微軟翻譯api的詳細使用有作詳細介紹。?
?? 二,去申請key,進入http://www.bing.com/developers/createapp.aspx,填寫相關的你的應用信息就行了。就會有下面的圖片中顯示的key,中的Application ID就是key。?
? 三、下面給個實例:?
Java代碼??
?
四、運行結果:Property?
?
這里說下可能出現的問題:
1、android下要用microsoft-translator-java-api-0.6-jar-with-dependencies.jar,否則運行時可能會報錯android java.lang.NoClassDefFoundError: org.json.simple.JSONValue。
2、使用過程中出現錯誤:TranslateApiException: Cannot find an Azure Market Place Translator Subscription associated with the request credentials,則需要到網址上先訂閱translate api的免費流量,操作如下:
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)
轉載于:https://www.cnblogs.com/brainy/archive/2012/05/24/2516487.html
總結
以上是生活随笔為你收集整理的微软翻译api的使用介绍和注意事项的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: socket编程资料-网络收集
- 下一篇: ios启动画面