This commit is contained in:
2022-06-26 17:15:01 +08:00
parent 8d3dfd33fe
commit ebf3415f38
+12 -7
View File
@@ -19,9 +19,11 @@ local function get_access_token()
ngx.log(ngx.INFO, 'HtySudoerToken -> ', sudoerToken)
local remote_url = string.format("%s/api/v1/uc/wx_get_access_token", htyuc)
ngx.log(ngx.INFO, 'remote_url -> ', remote_url)
ngx.log(ngx.INFO, 'REMOTE URL -> ', remote_url)
local res, err = httpc:request_uri(
ngx.log(ngx.INFO, "START REQUEST TO GET ACCESS TOKEN")
local resp, err = httpc:request_uri(
remote_url,
{
ssl_verify = false, -- 设置参数 ssl_verify 为false 不校验ssl证书
@@ -33,17 +35,20 @@ local function get_access_token()
}
)
if res == nil then
ngx.log(ngx.INFO, "RESP -> ", resp)
ngx.log(ngx.ERR, "ERR -> ", err)
if resp == nil then
ngx.log(ngx.ERR, "FAILED TO CONNECT TO *HTYUC*", err)
end
if 200 ~= res.status then
if 200 ~= resp.status then
ngx.log(ngx.ERR, "GET ACCESS TOKEN *FAILED*", err)
ngx.say(err)
ngx.exit(res.status)
ngx.exit(resp.status)
else
ngx.log(ngx.ERR, res.body)
return cjson.decode(res.body).d
ngx.log(ngx.ERR, "RESP IS OK -> ", resp.body)
return cjson.decode(resp.body).d
end
end