def send(url,data)
uri = URI.parse(url)
json = JSON.generate(data)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
req = Net::HTTP::Post.new(uri.path)
req.body = "postBody=#{json}"
req['Cookie'] = @agent.cookie_jar.cookies(URI.parse("https://secure.me.com")).map { |c| c.to_s }.join("; ")
req['X-Mobileme-Version'] = '1.0'
req['X-Mobileme-Isc'] = @isc
req['X-Requested-With'] = 'XMLHttpRequest'
req['Accept'] = 'text/javascript, text/html, application/xml, text/xml, */*'
req['Content-type'] = 'application/json'
res = http.start { |web|
web.request(req)
}
return JSON.parse(res.body)
end