嗨,伙计们,这是一个很大的问题和一个远大的目标,但是这里有,
我有一个经典的 ASP 网站,我想将注册过程集成到 facebook,但我不知道如何做到这一点。我已经搜索了几天并找到了各种信息,但我似乎仍然无法理解应该相当简单的过程。
我已经设法使用 facebook 部分进行注册,这会将 facebook 用户 ID 和 access_token 写入 SQL 数据库,但我不知道如何更改我的登录页面,以便我的网站知道用户已成功通过身份验证。
这是目前验证我的用户的代码。
<%
Const adCmdText = 1
'On Error Resume Next
SQSecureDSN="Provider=SQLNCLI10;Server=;Database=; Trusted_Connection=yes;"
Redirpath=""
Set SQLog = Server.CreateObject("ADODB.Connection")
SQLog.open SQSecureDSN
tmpUsername=replace(Request.Form("username"),"'","")
tmpUsername=replace(tmpusername,"""","")
tmpPW=replace(Request.Form("password"),"'","")
tmpPW=replace(tmpPW,"""","")
if tmpPW & "X" <> "X" Then
strSQL = "SELECT * FROM users WHERE username=? AND password=? AND enabled ='TRUE';"
Dim cmd1
Set cmd1 = Server.CreateObject("ADODB.Command")
cmd1.ActiveConnection = SQLog
cmd1.CommandText = strSQL
cmd1.CommandType = adCmdText
cmd1.Parameters(0) = tmpusername
cmd1.Parameters(1) = tmpPW
Set rstLogin = cmd1.Execute()
If rstLogin.EOF Then
ResponseMessage="<tr><td colspan=2><b><h1 style=color:red;>Login failed!</h1><br> <p>Have you activated your account?.. If not please <a href='submitreg.asp'>Click Here</a> </p></td></tr><tr><td><br></td></tr><tr><td colspan=2><p>If you have forgotten your password please <a href='mailto:xxxxx.com'>Click Here</a></p></td></tr><tr><td><br></td></tr>"
else
lognSQL= "SELECT [ID], client, admin ,username FROM users where username='" & tmpusername & "' AND password='" & tmpPW & "' AND enabled ='TRUE';"
Set logn = SQLog.execute(lognSQL)
if not logn.eof then
lookupun = logn("username")
lookupid = logn("ID")
lookupad = logn("admin")
lookupcl = logn("client")
end if
Session("usern") = tmpUsername
Session("AuthID") = lookupid
Session("admin") = lookupad
Session("clientID") = lookupcl
LogSQL= "UPDATE TSession SET clientID='" & lookupcl &"', userid='" & lookupid & "' where [Key]='" & Request("SessKey") & "';"
SQLog.execute(LogSQL)
RedirPath=request("redirect")
end if
SQLog.Close()
set SQLog = nothing
set SQConn = nothing
If Redirpath<>"" Then response.Redirect(Redirpath)
end if
%>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8">
<meta name="viewport" content="user-scalable=no, width=device-width" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta charset="utf-8">
<link rel="stylesheet" type="text/css"
href="css/iphone.css" media="only screen and (max-width: 480px)" />
<link rel="stylesheet" type="text/css"
href="css/page.css" media="screen and (min-width: 481px)" />
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script>
setTimeout(function () {
window.scrollTo(0, 1);
}, 1000);
</script>
<title>xxxxxxxx.com</title>
</head>
<body id='header'>
<%
Function Is_Mobile()
Set Regex = New RegExp
With Regex
.Pattern = "(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|windows ce|pda|mobile|mini|palm)"
.IgnoreCase = True
.Global = True
End With
Match = Regex.test(Request.ServerVariables("HTTP_USER_AGENT"))
If Match then
Is_Mobile = True
Else
Is_Mobile = False
End If
Dim user_agent
user_agent = Request.ServerVariables("HTTP_USER_AGENT")
If InStr(1, user_agent, "ipad", 1) Then
Is_ipad = true
Is_Mobile = False
Else
Is_ipad = False
End If
End Function
If Is_Mobile= True Then
%>
<img align="center" class="mainlogo" id="mainlogo" src="logo_banner.jpg"/>
<%
Else
%>
<!--#include file="css/twitter.html"-->
<!--#include file="css/facebook.html"-->
<!--#include file="css/tophead.html"-->
<%
End If%>
<%
if Session("clientID") = "" then
%>
<!--#include file="css/navibar.html"-->
<%
Else
%>
<!--#include file="css/clientnavibar.html"-->
<%
End if
%>
<p> <%=LeftPane%></p>
<p> </p>
</aside>
<!-- end .sidebar1 --></div>
<article class="content" id="content">
<section>
<br><p><h1>Please sign in or register to continue...</h1></p><br>
<p><form action="authenticate.asp" method=post>
<table border=0 align="center">
<%=ResponseMessage%>
<tr><td><b>
Username: </b></td><td><input name="username" size=16 width=20>
</td></tr><tr><td><b>
Password: </b></td><td><input type="password" name="Password" size=16 width=20>
</td></tr><tr><td></td><td>
<input type="hidden" name="redirect" value="<%=request("redirect")%>">
<input type="hidden" name="SessKey" value="<%=request("SessKey")%>">
<INPUT TYPE="submit" class="buttons" value="Login">
</td></tr></table>
<br>
<p><a href="register.asp">Not registered?.. Click Here</a></p>
<br><br>
</section>
<!-- end .content --></article>
<aside>
<p><strong></strong></p>
</aside>
<!--#include file="css/footer.html"-->
<!-- end .container --></div>
</body>
</html>
我已经在 facebook 上注册了一个应用程序,并且这一切都正确配置。