<!--#include file="../p_inc/config.asp"-->
<!--#include file="jo.asp"-->
<!--#include file="smart.1.asp"-->
<!--#include file="sha1.asp"-->
<%
response.Charset="utf-8"
set retTbl = jo.HashTable()
retTbl.FromRequest 0
if not retTbl.Exists("oauth_token") then
	response.Write "登录失败：" & request.QueryString
	response.End()
end if
url_get_noauth = "http://openapi.qzone.qq.com/oauth/qzoneoauth_access_token"
set table = jo.HashTable()
table.add "oauth_consumer_key",appid  
table.add "oauth_nonce",int(rnd * 1000000000)
table.add "oauth_timestamp",utc()/1000-8*3600
table.add "oauth_version","1.0"  
table.add "oauth_signature_method","HMAC-SHA1"
table.add "oauth_token",retTbl.Items("oauth_token")
table.add "oauth_vericode",retTbl.Items("oauth_vericode")
table.sort "asc","key"

'获取待签名字符串和密钥
oauth_signature="GET" & "&" & utf8(url_get_noauth) & "&" & utf8(table.URIString("no"))
seckey = appkey & "&" & session("oauth_token_secret1")

'计算签名
oauth_signature = b64_hmac_sha1(seckey,oauth_signature)
table.add "oauth_signature",oauth_signature

'发送请求
set http = SmartHttp(url_get_noauth & "?" & table.URIString("utf-8"))
http.autoClearBuffer = false
varresult = http.send().gettext("utf-8")
set table1 = jo.HashTable()
table1.FromRequest 2,varresult
if not table1.Exists("oauth_token") then
	response.Write "登录失败，错误代码：" & varresult
	response.End()
end if
session("oauth_token") = table1.Items("oauth_token")
session("oauth_token_secret") = table1.Items("oauth_token_secret")
session("openid") = table1.Items("openid")
response.Redirect "userinfo.asp"
%>