Foxtable(狐表)用户栏目专家坐堂 → 請求指導


  共有2873人关注过本帖树形打印复制链接

主题:請求指導

美女呀,离线,留言给我吧!
catyin1989
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:165 积分:1647 威望:0 精华:0 注册:2012/9/12 21:46:00
請求指導  发帖心情 Post By:2015/9/10 16:41:00 [只看该作者]

很想寫一個翻譯的功能,但是這些碼看不懂,請求大大幫忙把這些碼轉成 VB 或是 foxtable T^T

https://msdn.microsoft.com/en-us/library/ff512421.aspx

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/9/10 17:15:00 [只看该作者]

Mark 百度翻译API

 

http://developer.baidu.com/wiki/index.php?title=%E5%B8%AE%E5%8A%A9%E6%96%87%E6%A1%A3%E9%A6%96%E9%A1%B5/%E7%99%BE%E5%BA%A6%E7%BF%BB%E8%AF%91/%E7%BF%BB%E8%AF%91API

 

 

Dim text As String = "Use pixels to express measurements for padding and margins."

Dim client_id As String = "hAaa2NLELKdAIfMhMjnuEgi1"
Dim from As String = "auto"
Dim [To] As String = "auto"


Dim ScriptControl As Object, data  As Object, JscriptCode As String
JscriptCode = "function toUrl() {return encodeURI('" & text & "')}"
ScriptControl = CreateObject("MSScriptControl.ScriptControl")
With ScriptControl
    .Language = "Javascript"
    .Timeout = -1
    .AddCode(JscriptCode)
    text = .Run("toUrl")
End With

Dim url As String= "http://openapi.baidu.com/public/2.0/bmt/translate?client_id=" & client_id & "&q=" & text & "&from=" & from & "&to=" & [To]

Dim rqst As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(url)

Dim rsps As System.Net.HttpWebResponse = rqst.GetResponse

Dim stm As System.IO.Stream = rsps.GetResponseStream()

Dim reader As New System.IO.StreamReader(stm)

Dim str As String = reader.ReadToEnd

rsps.Close
stm.Close
reader.close


JscriptCode = "function toObject(json) {eval(""var o=""+json);return o;}"
ScriptControl = CreateObject("MSScriptControl.ScriptControl")
With ScriptControl
    .Language = "Javascript"
    .Timeout = -1
    .AddCode(JscriptCode)
    data = .Run("toObject", str)
End With
output.show(str)
For Each o As object In data.trans_result
    output.show(o.src)
    output.show(o.dst)
Next

 


 回到顶部
美女呀,离线,留言给我吧!
catyin1989
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:165 积分:1647 威望:0 精华:0 注册:2012/9/12 21:46:00
  发帖心情 Post By:2015/9/10 17:52:00 [只看该作者]

超級感謝的!!!!! >^<

 回到顶部
美女呀,离线,留言给我吧!
catyin1989
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:165 积分:1647 威望:0 精华:0 注册:2012/9/12 21:46:00
  发帖心情 Post By:2016/2/21 17:42:00 [只看该作者]

現在百度翻譯的網址好像不同了, 原碼不能用?? 能有新的code可用嗎?? T^T

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/2/21 18:48:00 [只看该作者]

注册成为百度开发者,然后参考

 

http://api.fanyi.baidu.com/api/trans/product/apidoc

 

MD5加密参考

 

msgbox(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("加密内容", "MD5"))

 

随机数参考

 

http://www.foxtable.com/help/topics/0349.htm

 

 


 回到顶部
美女呀,离线,留言给我吧!
catyin1989
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:165 积分:1647 威望:0 精华:0 注册:2012/9/12 21:46:00
  发帖心情 Post By:2016/2/21 19:11:00 [只看该作者]

必須用大陸的手機碼注冊.... 

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/2/21 22:16:00 [只看该作者]

如下代码,appid和key最好还是你自己注册一个

 

Dim q As String = "Use pixels to express measurements for padding and margins."
Dim from As String = "en"
Dim [To] As String = "zh"
Dim appid As String = "20160221000012908"
Dim salt As String = Rand.Next(1000000000)
Dim key As String =  "4aopMWtb_LTkwYNSJToE"

Dim text As String = appid & q & salt & key
Dim sign As String = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(text, "MD5")
sign = sign.ToLower

Dim ScriptControl As Object, data  As Object, JscriptCode As String
JscriptCode = "function toUrl() {return encodeURI('" & q & "')}"
ScriptControl = CreateObject("MSScriptControl.ScriptControl")
With ScriptControl
    .Language = "Javascript"
    .Timeout = -1
    .AddCode(JscriptCode)
    text = .Run("toUrl")
End With

Dim url As String= "http://api.fanyi.baidu.com/api/trans/vip/translate?q=" & text & "&from=" & from & "&to=" & [To] & "&appid=" & appid & "&salt=" & salt & "&sign=" & sign

Dim rqst As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(url)

Dim rsps As System.Net.HttpWebResponse = rqst.GetResponse

Dim stm As System.IO.Stream = rsps.GetResponseStream()

Dim reader As New System.IO.StreamReader(stm)

Dim str As String = reader.ReadToEnd

rsps.Close
stm.Close
reader.close


JscriptCode = "function toObject(json) {eval(""var o=""+json);return o;}"
ScriptControl = CreateObject("MSScriptControl.ScriptControl")
With ScriptControl
    .Language = "Javascript"
    .Timeout = -1
    .AddCode(JscriptCode)
    data = .Run("toObject", str)
End With
output.show(str)
For Each o As object In data.trans_result
    output.show(o.src)
    output.show(o.dst)
Next


 回到顶部
美女呀,离线,留言给我吧!
catyin1989
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:165 积分:1647 威望:0 精华:0 注册:2012/9/12 21:46:00
  发帖心情 Post By:2016/2/22 14:57:00 [只看该作者]

Dim sign As String = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(text, "MD5")
這句出 error, 說 security is not a member of web, 應如何更改??



 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/2/22 14:58:00 [只看该作者]

 添加引用那里,填入 System.Web.Dll

 

http://www.foxtable.com/help/topics/1936.htm

 

 


 回到顶部