我想使用Microsoft Translate API,我已经卡住了获取访问令牌。
这就是我的代码的样子:
authUri = "https://datamarket.accesscontrol.windows.net/v2/OAuth2-13/"
paramHash = {
"client_id" => "test",
"client_secret" => "*****",
"scope" => "http://api.microsofttranslator.com",
"grant_type" => "client_credentials"
}
postData = Net::HTTP.post_form(URI.parse(authUri), paramHash)
puts postData.body
但这不会终止,一段时间后我会收到超时错误:
`rescue in rbuf_fill': Timeout::Error (Timeout::Error)
我已经尝试了a Rest-Client宝石和卷曲。两者都工作得很好,但我不喜欢将另一颗宝石用于这么简单的任务。
当我将发布请求发送到localhost并使用netcat监听时,我看到完全相同的请求(User-Agent除外,但即使更改它也没有解决问题)