0

I am developing an application in iOS where I need to add a functionality to switch the application language in Chinese/English. I am using Baidu API to achieve this. I am able to translate single world or complete one sentence. But suppose my has multiple text which I need to place at diff location then either I have to hit the API multiple times or by wrapping all into one API. I have followed their documentation but nothing seems work. As per their documentation..... 1. How do I translate multiple words or more text in a request? You can use the newline (in the majority of the programming language for the escape symbol \ n) in the sent field q to separate the multiple words or pieces of text to be translated so that you can get multiple words or multiple text independent translations The result. Note that before sending the request to the q field do URL encode!

And I am trying to get the result for this....

appid = 2015063000000001 + q = apple + salt = 1435660288 + key = 12345678

Let me give an example: Suppose I need to convert two different word. “apple” and “mango”

2015063000000001+apple\ nmango+1435660288+7_8ogRLnl7PO52O0UYd2  
2015063000000001apple\n mango143566028812345678         (Get the MD5 = c0610b314af72e42a4a5b9e62757faf7)

http://api.fanyi.baidu.com/api/trans/vip/translate?q=apple\nmango&from=en&to=zh&appid=2015063000000001&salt=1435660288&sign=c0610b314af72e42a4a5b9e62757faf7

When I am hitting above url on chrome then getting this result.

Result : {"error_code":"54001","error_msg":"Invalid Sign”}
MatejMecka
  • 1,448
  • 2
  • 24
  • 37
tauheed
  • 161
  • 1
  • 12

1 Answers1

0

Now I got the answer for my question. In URL replace "\n" with URL encode "%0A". Also generate MD5 via the code not from online.

tauheed
  • 161
  • 1
  • 12