require 'uri' require 'net/http' require 'net/https' require 'json' module GM # 网络请求 class Network ## post请求 def Network.post (url,body) # puts "start net request:#{body}" uri = URI.parse(url) https = Net::HTTP.new(uri.host,uri.port) https.use_ssl = true request = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' =>'application/json'}) request["x-tt-env"] = "boe_csj_sdk" request["Cookie"]="__union_admin_sess_cookie=232301_noduimkpdwrbyrkr1qih; _ssa_userphone=; _ssa_username=zhangtianhao.1230" request.body = body.to_json res = https.request(request) if res.code == "200" data = JSON.parse(res.body) # puts "finish net request:#{data}" return data else ## 网络请求异常的提示 puts "请求失败 : Response code = #{res.code}, message = #{res.message}" end nil end def Network.request_adapter(body) data = post("https://www.csjplatform.com/union_pangle/api/sdk_adapter/query",body) end end end