微信授权代码翻译样本


var a,b,c,d = ngx.call(1,2,3)
var e = [];

var f ;

var g = function () {}
var h = 1;
var c = "abcdefg" + "222";
var d = "asdasdasd" + a;
var a = ngx >>> log();


array or object
a["c"] =  1;
a.c=1;
a++;
a+=1;

a[0] = 1;
a[i] = 1;

var a = {"a":1}
var b = {b:1}
var c = 2+2;
var d = d+d;

ngx.header["Content-Type"] = "text/plain";
ngx.header["Server"] = "openn2o server 0.1.4";


var http = require("resty.http")
var data = ngx.req.get_uri_args() ;

var code = data["code"];
var appId= "222"
var appSe= "222"
var request = http.new() ;
var url     = "https://api.weixin.qq.com/sns/jscode2session?appid=" + appId + "&secret=" + appSe +
"&js_code="+ code+ "&grant_type=authorization_code"  

var res, err = request >>> request_uri (url, 
{	
	ssl_verify:false,
	method:"GET"
}
);
  
ngx.log(ngx.ERR, res.status, res.body, err);

if(res == null) {
	 ngx.log(ngx.ERR, "err:auth failed..")
	 ngx.exit(502)
	 return;
}

if(e.status == 200) {
	 ngx.say(res.body);
}
    

翻译之后结果:

$ make lua
rm -f ./build/*.js
==================lexer is build========================
lua def.lua ./build/tmp.js ./build/tmp.js SCRIPT=lua  DEBUG=1
run macro define list
SCRIPT  :       lua
DEBUG   :       1
run compile and macro handler. and input file path is ./build/tmp.js
execute result .... wait...
run result done and outfile path is ./build/tmp.js
done
cp -f ./build/tmp.js ./build/lexer_boxer
node ./build/tmp.js build/benchmark_define_vars.ts
lua mode.
1 : local a,b,c, d=ngx.call (1,2,3)
2 : e
3 : f
4 : g
5 : local h=1
6 : local c="abcdefg".."222"
7 : local d="asdasdasd"..a
8 : local a=ngx:log ()
9 : a["c"]=1
10 : a.c=1
11 : a=a+1
12 : a=a+1
13 : a[0]=1
14 : a[i]=1
15 : local a={
["a"] = 1
}
16 : local b={
["b"] = 1
}
17 : local c=2+2
18 : local d=d+d
19 : ngx.header["Content-Type"]="text/plain"
20 : ngx.header["Server"]="openn2o server 0.1.4"
21 : local http=require ("resty.http")
22 : local data=ngx.req.get_uri_args ()
23 : local code=data["code"]
24 : local appId="222"
25 : local appSe="222"
26 : local request=http.new ()
27 : local url="https://api.weixin.qq.com/sns/jscode2session?appid="..appId.."&secret="..appSe.."&js_code="..code.."&grant_type=authorization_code"
28 : local res, err=request:request_uri (url,{
["ssl_verify"] = false,
["method"] = "GET"
})
29 : ngx.log (ngx.ERR,res.status,res.body,err)
30 :
if res==nil then
ngx.log (ngx.ERR,"err:auth failed..")
ngx.exit (502)

end

31 :
if e.status==200 then
ngx.say (res.body)
end

cp ./build/tmp.js ./build/lualexer
cp -f ./build/lualexer ../build/
echo "make lua kernel done"
make lua kernel done

 

转载于:https://my.oschina.net/littlemonkeyc/blog/1858974

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值