Today, I guide you use Microsoft Translator API in Application iOS.
With Microsoft Translator API FREE , you have 2.000.000 characters/month use translate. Code Demo Microsoft Translator API for iOS
Step 1: Create an account Microsoft and register application translator with Microsoft translator API.
Go to page: https://signup.live.com/signup.aspx?lic=1
Note: Client ID is Customer ID get from My Account Info
Step 2: You read concept Authorization, Obtaining an Access Token, Subscription ... on page http://msdn.microsoft.com/en-us/library/dd576287.aspx
With 2 steps: --> A. Get Access Token
--> B. Use Access Token send request to server.
With format url http://api.microsofttranslator.com/v2/Http.svc/Translate?text=<text translator >&from=<language from>&to=<language to>
And Add to header field “Authorization”, value is “Bearer <access token>” (with <access token> get from A.)
OK.
Step 3: Demo translator with class MSBingTranslator.
Create New Project witch name MSBingTranslatorDemo
Copy class MSBingTranslator to project.
Note: Copy your Client ID and your Client Secret had register to bingApp_ID, bingClientSecret in file MSBingTranslator.h line 38, 32
And button Translator with event Touch Up Insite is function btnTranslator
In ViewController define MSBingTranslator *_bingTranslator;
In viewDidLoad init _bingTranslator and set delegate.
In file ViewController.h, use MSBingTranslatorDelegate with Three function translatedText:, detectedLanguage:, failedWithError:.
In file ViewController.m, use Three function of MSBingTranslator get Text Translator
In Function btnTranslator call translateText: if translator success, delegate translatedText: call auto
Thanks!!
If you have any questions or comments about Microsoft Translator API for iOS, please comment below!