Sha256: c1a9b081b276ad6e1025546d9f386eb3fbb7ff93167bc0ee737cce52dd84f7a1
Contents?: true
Size: 1.35 KB
Versions: 4
Compression:
Stored size: 1.35 KB
Contents
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 def Network.push_track(body) data = post("https://gromore.pangolin-sdk-toutiao.com/api/ad/union/mediation/stats/",body) end end end
Version data entries
4 entries across 4 versions & 1 rubygems