我需要将一些xml信息发布到restful api,有人能给我一个如何做到这一点的提示吗?我使用的是rails。
发布于 2010-10-22 23:22:26
在rails中,使用ActiveResource,您可以这样做:
class PersonResource < ActiveResource::Base
self.site = "http://api.people.com:3000/"
self.proxy = "http://user:password@proxy.people.com:8080"
end
ryan = Person.new(:first => 'Ryan', :last => 'Daigle')
# the next line posts this object serialized to xml to the configured url
ryan.save # => truehttp://api.rubyonrails.org/classes/ActiveResource/Base.html
如果您要发布的站点具有自定义应用编程接口(不是活动资源),则必须使用Net:HTTP
https://stackoverflow.com/questions/3998250
复制相似问题