Hi,
I am a newbie of ruby. This days I’ve been trying to write some
translator
plugin for vim using ruby httparty.
but I was trapped in the first step…
code:
require ‘httparty’
class ZetaTranslator
include HTTParty
base_uri ‘https://datamarket.accesscontrol.windows.net’
headers “User-Agent” => “toolbar”, “Content-length” => “0”
def initialize(id, secret)
@options = {
:grant_type => ‘client_credentials’,
:client_id => id,
:client_secret => secret,
:scope => ‘http://api.microsofttranslator.com’,
}
end
def getAccessToken
self.class.post(‘/v2/OAuth2-13/’, @options)
end
end
puts ZetaTranslator.new(‘zetatrans’,
‘vOZMcqNT50ee06hkbUzt4ZmqOveVNl8HXphnVIxD7NU=’).getAccessToken
it gives me a result as shown below:
{“error”=>“invalid_request”, “error_description”=>“ACS90004: The request
contains 1 tokens separated by ‘=’ instead of a single key value pair.
\r\nTrace ID: 5d37e365-0477-47a5-b78e-ba61bcd4a995\r\nTimestamp:
2012-07-12
02:22:52Z”}
I’ve tried google, but failed to find a solution. please help me.
thanks!
(wish you could understand my poor english…)