<!--#include file="../p_inc/config.asp"-->
<!--#include file="jo.asp"-->
<!--#include file="smart.1.asp"-->
<!--#include file="sha1.asp"-->
<%
response.Charset="utf-8"
url_get_noauth = "http://openapi.qzone.qq.com/oauth/qzoneoauth_request_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.sort "asc","key"

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

'计算签名
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 table1.Exists("oauth_token") then
	session("oauth_token_secret1") = table1.Items("oauth_token_secret")
	response.Redirect "http://openapi.qzone.qq.com/oauth/qzoneoauth_authorize?oauth_consumer_key=" & appid & "&oauth_token=" & table1.Items("oauth_token") & "&oauth_callback=" & utf8(callback)
else
	response.Write "登录失败，错误代码：" & varresult
end if
%>