From: Feng Chen Date: 2012-07-12T11:32:27+09:00 Subject: problem with HTTParty when get bing translator api access token --bcaec52be46313853e04c498c6f6 Content-Type: text/plain; charset=ISO-8859-1 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...) --bcaec52be46313853e04c498c6f6 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi,

I am a newbie of ruby. This days I've been tryin= g to write some translator plugin for vim using ruby httparty.
bu= t I was trapped in the first step...

code:
=3D=3D=3D=3D
require 'httparty'

<= /div>
class ZetaTranslator
=A0 include HTTParty
=A0= base_uri 'htt= ps://datamarket.accesscontrol.windows.net'
=A0 headers "User-Agent" =3D> "toolbar", "= Content-length" =3D> "0"
=A0=A0
=A0 d= ef initialize(id, secret)
=A0 =A0 @options =3D {
=A0 = =A0 =A0 :grant_type =3D> 'client_credentials',
=A0 =A0 =A0 :client_id =3D> id,
=A0 =A0 =A0 :client_secre= t =3D> secret,
=A0 =A0 =A0 :scope =3D> 'http://api.microsofttranslator.com'= ,
=A0 =A0 }
=A0 end

=A0 def getAccessToken
=A0 = =A0 self.class.post('/v2/OAuth2-13/', @options)
=A0 end
end

puts ZetaTranslator.new('zetatran= s', 'vOZMcqNT50ee06hkbUzt4ZmqOveVNl8HXphnVIxD7NU=3D').getAccess= Token
=3D=3D=3D

it gives me a result as shown= below:
=3D=3D=3D
{"error"=3D>"i= nvalid_request", "error_description"=3D>"ACS90004: T= he request contains 1 tokens separated by '=3D' instead of a single= key value pair. \r\nTrace ID: 5d37e365-0477-47a5-b78e-ba61bcd4a995\r\nTime= stamp: 2012-07-12 02:22:52Z"}
=3D=3D=3D

I've tried google, but fa= iled to find a solution. please help me.
thanks!

(wish you could understand my poor english...)
--bcaec52be46313853e04c498c6f6--