Module: HqTencentDspApi
- Defined in:
- lib/hq_tencent_dsp_api.rb,
lib/hq_tencent_dsp_api/version.rb
Constant Summary collapse
- DSP_ID =
'190'- TOKEN =
'73553e669b7270a4934706f76a99ad36'- AD_LIST_URL =
广告位信息同步API
'http://opentest.adx.qq.com/location/list'- UPLOAD_ORDER_URl =
广告信息同步API
'http://opentest.adx.qq.com/order/sync'- DENY_STATUS_URL =
获取审核未通过的广告信息API
'http://opentest.adx.qq.com/file/denylist'- GET_STARTUS_URL =
批量获取广告的审核状态
'http://opentest.adx.qq.com/order/getstatus'- UPLOAD_CUSTOMER_INFO_URL =
批量上传客户信息审核
'http://opentest.adx.qq.com/client/sync'- GET_CUSTOMER_STATUS_URL =
批量获取客户的审核信息
'http://opentest.adx.qq.com/client/info'- GET_QUALITIFIED_URL =
获取审核通过客户的信息
'http://opentest.adx.qq.com/client/quali'- REPORT_FORM_URL =
获取腾讯一个时间段内的数据报表
'http://opentest.adx.qq.com/order/report'- VERSION =
"0.1.0"
Class Method Summary collapse
-
.get_ads_info_of_deny(upload_date) ⇒ Object
获取审核未通过的广告信息.
-
.get_customer_qualitied ⇒ Object
获取审核通过客户的信息.
-
.get_customer_status(names) ⇒ Object
> “ret_msg”=>{“浩趣互动”=>{“verify_status”=>“待通过”, “audit_info”=>“”, “is_black”=>“N”, “type”=>“ADX”, “vocation”=>“”, “vocation_all”=>“”}, “error_code”=>0}.
-
.get_tencent_report_form(start_date, end_date) ⇒ Object
腾讯报表 –用于定时任务调取.
-
.load_ad_from_adx(date = nil) ⇒ Object
广告位信息同步————下载广告位信息.
-
.nums_of_ad_status(dsp_order_id_info) ⇒ Object
批量获取广告的审核状态 result = TencentAdList.new.nums_of_ad_status(.to_json) “ret_msg”=>{“total”=>1, “count”=>1, “records”=>{“48”=>[{“status”=>“待审核”, “client_name”=>“浩趣互动”, “file_count”=>“1”, “file_info“=>, ”targeting_url“=>”dsp.hogic.cn“, ”monitor_url“=>”[]“, ”monitor_position“=>]}}, “error_code”=>0}.
-
.upload_customer_info_confirm(client_info) ⇒ Object
客户信息同步———-批量上传客户信息.
-
.upload_order_info(order_info) ⇒ Object
Your code goes here…
Instance Method Summary collapse
-
#getTrackingUrl(hqAdId, hqCreativeId, hqSource = 'youku', hqEvent = 1) ⇒ Object
添加一个地址.
- #post(url, params) ⇒ Object
Class Method Details
.get_ads_info_of_deny(upload_date) ⇒ Object
获取审核未通过的广告信息
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/hq_tencent_dsp_api.rb', line 42 def self.get_ads_info_of_deny(upload_date) url = DENY_STATUS_URL params = { "dsp_id"=>DSP_ID, "token"=>TOKEN, "upload_date"=>upload_date } result = post(url,params) return result end |
.get_customer_qualitied ⇒ Object
获取审核通过客户的信息
114 115 116 117 118 119 120 121 122 |
# File 'lib/hq_tencent_dsp_api.rb', line 114 def self.get_customer_qualitied url = GET_QUALITIFIED_URL params = { "dsp_id"=>DSP_ID, "token"=>TOKEN, } result = post(url,params) return result end |
.get_customer_status(names) ⇒ Object
> “ret_msg”=>{“浩趣互动”=>{“verify_status”=>“待通过”, “audit_info”=>“”, “is_black”=>“N”, “type”=>“ADX”, “vocation”=>“”, “vocation_all”=>“”}, “error_code”=>0}
101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/hq_tencent_dsp_api.rb', line 101 def self.get_customer_status(names) url = GET_CUSTOMER_STATUS_URL params={ "dsp_id"=>DSP_ID, "token"=>TOKEN, "names"=>names||[] } p params result = post(url,params) return result end |
.get_tencent_report_form(start_date, end_date) ⇒ Object
腾讯报表 –用于定时任务调取
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/hq_tencent_dsp_api.rb', line 125 def self.get_tencent_report_form(start_date,end_date) url = REPORT_FORM_URL #由于start_date 跟end_date之间的差值超过7腾讯会直接报错,所以这地方判断一下,超过7就直接退出不去请求 s= Date.parse(start_date)-Date.parse(end_date) if !s.nil? && s.to_i>7 raise '请求下载报表数据不能超过一周' end params = { "dsp_id"=>DSP_ID, "token"=>TOKEN, "start_date"=>start_date, "end_date"=>end_date } result = post(url,params) if result["ret_code"].to_i != 0 raise "请求错误 #{result}" end return result end |
.load_ad_from_adx(date = nil) ⇒ Object
广告位信息同步————下载广告位信息
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/hq_tencent_dsp_api.rb', line 30 def self.load_ad_from_adx(date=nil) url = AD_LIST_URL params = { "dsp_id" => DSP_ID, "token"=>TOKEN, "date"=> (date.nil? ? '' : date) } result = post(url,params) return result end |
.nums_of_ad_status(dsp_order_id_info) ⇒ Object
批量获取广告的审核状态result = TencentAdList.new.nums_of_ad_status(.to_json) “ret_msg”=>{“total”=>1, “count”=>1, “records”=>{“48”=>[{“status”=>“待审核”, “client_name”=>“浩趣互动”, “file_count”=>“1”, “file_info“=>, ”targeting_url“=>”dsp.hogic.cn“, ”monitor_url“=>”[]“, ”monitor_position“=>]}}, “error_code”=>0}
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/hq_tencent_dsp_api.rb', line 57 def self.nums_of_ad_status(dsp_order_id_info) url = GET_STARTUS_URL # url = URI.parse(url) params = { "dsp_id"=>DSP_ID, "token"=>TOKEN, "dsp_order_id_info"=>dsp_order_id_info } result = post(url,params) return result end |
.upload_customer_info_confirm(client_info) ⇒ Object
客户信息同步———-批量上传客户信息
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/hq_tencent_dsp_api.rb', line 86 def self.upload_customer_info_confirm(client_info) url = UPLOAD_CUSTOMER_INFO_URL params = { "dsp_id"=>DSP_ID, "token"=>TOKEN, "client_info"=>client_info||[] } result = post(url,params) return result end |
.upload_order_info(order_info) ⇒ Object
Your code goes here…
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/hq_tencent_dsp_api.rb', line 15 def self.upload_order_info(order_info) url = UPLOAD_ORDER_URl params = { 'dsp_id' => DSP_ID, 'token' => TOKEN, } order_info = {"order_info"=>order_info} url = URI.parse(url) parameters = params.merge(order_info) result = Net::HTTP.post_form(url,parameters) return result end |
Instance Method Details
#getTrackingUrl(hqAdId, hqCreativeId, hqSource = 'youku', hqEvent = 1) ⇒ Object
添加一个地址
146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/hq_tencent_dsp_api.rb', line 146 def getTrackingUrl(hqAdId,hqCreativeId,hqSource='youku',hqEvent=1) sql = "select *,hq_expand_ad.id as aid from hq_expand_ad left join hq_expand_plan on hq_expand_ad.plan=hq_expand_plan.id where hq_expand_ad.id=#{hqAdId}" conn = ActiveRecord::Base.connection_pool.checkout results = conn.select_all(sql).to_hash result = results[0] hqClientId = result['company'] hqAdId = result['aid'] hqGroupId = result['plan'] # $hqCreativeId = $result['originality']; return "http://track.hogic.cn/api/ads?hqClientId=#{hqClientId}&hqGroupId=#{hqGroupId}&hqAdId=#{hqAdId}&hqCreativeId=#{hqCreativeId}&hqSource=#{hqSource}&hqEvent=#{hqEvent}" end |
#post(url, params) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/hq_tencent_dsp_api.rb', line 69 def post(url,params) url = URI(url) # http = Net::HTTP.new(url.host,url.port) # request = Net::HTTP::Post.new(http.request_uri) # request.body = params.to_json # response = http.request(request) # result = response.body result = Net::HTTP.post_form(url,params) result = ActiveSupport::JSON.decode(result.body) if result["ret_code"].to_i!=0 raise "请求错误:#{result}" end return result end |