顺丰 丰桥对接 订单路由查询 ruby rails

def self.get_express_route_test
  url = 'http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService'
  xml = "<Request service='RouteService' lang='zh-CN'><Head>4545</Head><Body><RouteRequest tracking_type='1' method_type='1' tracking_number='444003077898'/></Body></Request>"
  keyword = 'dsadsa'
  md5_str = Digest::MD5.digest((xml + keyword).encode('utf-8'))
  verifyCode = Base64.strict_encode64(md5_str)
  uri = URI.parse(url)
  req = Net::HTTP::Post.new(uri.path,{'Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8'})
  req.body = "xml=#{xml}&verifyCode=#{verifyCode}"
  req = Net::HTTP.new(uri.host,uri.port).start{|http| http.request(req)}
  Rails.logger.debug req.body
end

  

posted @ 2018-09-07 16:59  皓贤  阅读(2167)  评论(0编辑  收藏  举报