Commit cba6f722 by zmj

fix huawei 推送参数

parent 97818129
...@@ -33,7 +33,7 @@ module AppPush ...@@ -33,7 +33,7 @@ module AppPush
ver: '1', ver: '1',
appId: config['app_id'] appId: config['app_id']
} }
url = "https://api.push.hicloud.com/pushsend.do?nsp_ctx=#{URI.escape(nsp_ctx.to_s)}" url = "https://api.push.hicloud.com/pushsend.do?nsp_ctx=#{CGI::escape(nsp_ctx.to_json)}"
AppPush::Log.info("url: #{url}") AppPush::Log.info("url: #{url}")
AppPush::Log.info("body: #{body}") AppPush::Log.info("body: #{body}")
response = HTTParty.post(url, body: body, headers: headers, timeout: 5) response = HTTParty.post(url, body: body, headers: headers, timeout: 5)
...@@ -51,13 +51,19 @@ module AppPush ...@@ -51,13 +51,19 @@ module AppPush
} }
} }
} }
{ params = {
access_token: 'access_token', access_token: CGI.escape(access_token),
nsp_svc: 'openpush.message.api.send', nsp_svc: CGI.escape('openpush.message.api.send'),
nsp_ts: Time.now.to_i, nsp_ts: CGI.escape(Time.now.to_i.to_s),
device_token_list: device_tokens, # 单次最多100 device_token_list: CGI.escape(device_tokens.to_s),
payload: payload payload: CGI.escape(payload.to_json)
} }
params_str = ''
params.each_with_index do |(key,value), index|
params_str += "#{key}=#{value}"
params_str += '&' if index + 1 < params.size
end
params_str
end end
def handle_token_res def handle_token_res
...@@ -89,4 +95,4 @@ module AppPush ...@@ -89,4 +95,4 @@ module AppPush
end end
end end
end end
end end
\ No newline at end of file
module AppPush module AppPush
VERSION = "0.1.2.1" VERSION = "0.1.3"
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment