Pergunta

I am trying to serialized an AMF body and send it with RestClient.post.

From the Charles proxy, I can deserialized my request body and show it as follows:

# s is the raw binary from request body
pp RocketAMF::Envelope.new.populate_from_stream(s).messages

enter image description here

However, I cannot figure it out how to serialize such an object and send it (with RestClient.post) in the body.

Foi útil?

Solução

You'll want to change the URL it's using, but the below is the correct way to do it.

require 'rubygems'
require 'RocketAMF'
require 'rest-client'

data = [] # whatever data you want
env = RocketAMF::Envelope.new :amf_version => 3
env.messages << RocketAMF::Message.new('BatchController.authenticate_iphone', '/1', data)
res = RestClient.post "http://localhost:9292/amf", env.to_s, :content_type => 'application/x-amf'
puts RocketAMF::Envelope.new.populate_from_stream(res).inspect
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top