Click here to Skip to main content
Click here to Skip to main content

Classic ASP Integration with Facebook Websites Feature

By , 2 Mar 2012
 

Introduction

When integrating with Facebook, I've always had to resort to PHP or .NET to get the job done. The new Facebook for Websites tool set combined with a few open source solutions makes this a snap with ASP. In this article, I hope to show you how it works, what tools you need to pull together and finally a suggestion for how to integrate with your website's existing login framework.

NOTICE: This code was revised for Facebook oAuth 2.0. It no longer uses the javascript components for logging in. If you have used this library in the past please read through the article you'll see the process is much easier than before but requires a slightly different setup. Read the section at the end titled "Converting Pre 2012 Code" for tips on converting existing code.

Background

There are two really slick tools I found to help solve the problem of translating Facebook's article from PHP to VBScript (the Facebook article can be found here).

First is the json2.asp library by Troy Foster and Doug Crawford. What is slick about this solution is that it takes advantage of an often forgotten feature of Classic ASP: you can run JScript and VBscript together as long as they are isolated in <script runat="server"></script> blocks. Usually, an IIS server is configured for vbscript so you only need the special runat tags when you want to specify a language other than the server default. For VBScript, <% %> tags should still work fine on most IIS servers.

The second cool tool I found is Flangy Development's implementation of URLDecode (found here). I'll go into the details later, but trust me, this is really slick!

A third library is also very useful MD5 encryption from http://www.frez.co.uk. I wrapped this into a class "encrypt".

To round out the tools I pulled together for this solution is Microsoft's KB246067 which provides a way to sort a dictionary object by key to emulate PHP's ksort.

Using the Code

Part of Facebook's validation requires MD5 to operate, it also requires that the list of cookie values is sorted first and assembled in a long string of variable=data sets called the payload. The values themselves are URLEncoded thus the need for an URLDecode function. There are many scripts available to do this; I was enamored by the elegance of the one I use in this example.

To leverage Facebook authentication, you need to first register your website on Facebook at http://developers.facebook.com/setup/. Once registered, you'll get an API Key and an Application Secret. Open fb_app.asp from the source code and populate the variables FACEBOOK_APP_ID with the API Key and FACEBOOK_SECRET with the application secret.

You also need to include two libraries in your pages that utilize Facebook authentication: The JSON2 library and the fb_app.asp library.

You include the JSON2 library using this tag:

<script language="JavaScript" runat="server" src="json2.asp"></script>

This is the script tag equivalent to a #INCLUDE FILE as used for server side includes. The fb_app.asp library is included using a standard include as follows:

 <!-- #INCLUDE FILE="fb_app.asp" -->

If you want to integrate the Facebook authentication mechanism with your existing authentication mechanism, you need to include code in the fb_main function of fb_app.asp that updates/adds the user information in your database and authenticates based on FB userid.

That takes care of the server side. In your HTML markup, you need to include the Facebook JavaScript library along with an anchor tag for your login button.

<a href="myfacebookauthpage.asp">Login using Facebook</a>

The anchor tag above should be placed where you want it to display in your HTML.

In your login code, include the following two lines to perform the authentication:

strJSON = get_json_cookie( cookies(<span lang="en-us">"</span>access_token") ) ' this is a function in fb_app.asp
Set user = JSON.parse( strJSON ) ' this is the JSON object from JSON2.ASP

The user object will now have name, id and email properties that you can access (user.id).

Your login page is now FB enabled!

A Closer Look at Facebook Interaction

The FACEBOOK_SCOPE value (found in facebook_app.asp) includes a request for permission to access the visitors' email address and stream by default. This is done because only the name and hometown information in the default dataset is otherwise available when a Facebook user allows your application. The Facebook user is told what fields you wish to access before approving your request. The example below shows the prompt for this login link.

This file is the “front end" and represents your login page. It includes the key server side libraries. Any libraries you need to add and the code necessary to support the Facebook login button as shown below:

When the user allows your application, Facebook creates a cookie for your website that grants you access to the FB userid and an access token. The access token is the key that enables you to retrieve the full set of allowed information. This requires a server-side call to Facebook. The challenge here is that Facebook returns JSON notation rather than XML. As such, you need to convert the JSON into something that can be manipulated by VBScript. Enter the first groovy tool: JSON2.ASP. The code below is an example of JSON returned by Facebook.

{
   "id": "9",
   "name": "FirstName LastName",
   "first_name": "FirstName",
   "last_name": "LastName",
   "link": "http://www.facebook.com/firstname.lastname",
   "about": "Rugby and Brats, enough said.",
   "birthday": "12/02",
   "hometown": {
      "id": 9999999999999999,
      "name": "Chicago, Illinois"
   },
   "location": {
      "id": 9999999999999999,
      "name": "Chicago, Illinois"
   },
   "bio": "I like cheese",
   "quotes": "Bears, Beats, Battlestar Galactica.",
   "gender": "female",
   "timezone": -6,
   "locale": "en_US",
   "verified": true,
   "email": "firstname.lastname@mysite.com",
   "updated_time": "2010-06-05T16:22:56+0000"
}  

The JSON2.ASP library cleverly utilizes Jscript on the server side to parse the JSON into an object that can then be referenced in VBScript. This is all made possible because ASP enables Jscript objects and VBScript to interact (albeit at a somewhat primitive level).

So all we have to do is get the page data as a string from Facebook and pass it as a string to the JSON object with the following code:

strJSON = get_json_cookie( cookies("access_token") ) ' this is a function in fb_app.asp
Set user = JSON.parse( strJSON ) ' this is the JSON object from JSON2.ASP

The user object is now populated. You can access the data from the user to register/update your database. In the code example, I write (response.write) a list of variables common to registration to get you started.

You can now integrate with your DB (see suggestions below).

Suggestions for DB Integration

Since everybody's login routine is a little different, I'll provide the most basic framework of a login mechanism and show how FB_APP can be added. In a classic database-driven authentication scenario, a user would visit a login page and type username and password into textboxes, then click a button to login. On submission of the login, the ASP page would look up the user record based on login and password if the login is invalid (recordset is empty) the user is prompted to try again. If the login is valid, the script would set a cookie or a session variable to indicate a login, then proceed to the homepage. The code would look something like this.

Function do_login()
    sUser = request.form("login")
    sPass = request.form("pass")
    Set conn = createobject(“adodb.connection") 
    Conn.connectionstring="your connection string"
    Conn.open
    Set rs = conn.execute( "SELECT * FROM users WHERE login='" _
	& sUser & “' and password='" & sPass & “';")    If rs.eof then
        Rs.close
        Conn.close
        Response.write "invalid login try again"
    Else
        Session("userid")=rs("userid")
        Rs.close
        Conn.close  
        Response.redirect("securepage.asp")
    End If
End function  

The first thing to do is add a field to your user table “fb_userid" as a bigint. This will be used to store the Facebook userid and correlate it back to a userid in your database. Then modify your login process to first try and lookup the user based on Facebook UserID, if a user is found set the session, if the user is not found register them and get their user record by Facebook UserID. Here is a modified version of the basic function above that does just that. Study it and work it into your own login code.

Function do_login()
    dim conn
    dim rs
    dim sUser
    dim sPass
    dim sFBID
    dim user
    dim strJSON
    dim fbcookie
    dim SQL
    
    Set conn = createobject("adodb.connection") 
    Conn.connectionstring="your connection string"
    Conn.open
    
    if request.servervariables("request_method")="POST" then
        ' it's a post/standard login
        sUser = request.form("login")
        sPass = request.form("pass")
        Set rs = conn.execute( "SELECT userid FROM users WHERE login='" & sUser & _
                 "' and password='" & sPass & "';")
        If rs.eof then
            Rs.close
            Response.write "invalid login try again"
        Else
            Session("userid")=rs(0)
            Rs.close
            conn.close
            set conn = nothing
            Response.redirect("securepage.asp")
        End If
    else
        ' attempt a Facebook style login
        
        ' do we have an FB Cookie
        if request.cookies("fbs_" & FACEBOOK_APP_ID)="" then 
            ' No Facebook login
        else
            ' We have Facebook info create a dictionary to contain the cookie info
            set fbcookie = get_facebook_cookie( FACEBOOK_APP_ID, FACEBOOK_SECRET )
            
            if fbcookie.count > 0 then 
                '' Use the access token to get the userinfo
                '' as a JSON a string from Facebook
                sToken = fbcookie("access_token")
                url = "https://graph.facebook.com/me?access_token=" & sToken
                strJSON = get_page_contents( URL ) 
                set user = JSON.parse( strJSON )
                
                set rs = conn.execute("SELECT userid FROM users _
				WHERE fb_userid=" & user.id )
                if rs.eof then 
                    ' record is empty add user
                    rs.close
                    set rs = nothing
                    SQL = "INSERT INTO users (first_name,last_name,email,fb_userid) " & _
                        "VALUES( " & _
                        " '" & replace( user.first_name, "'", "''" ) & "', " & _
                        " '" & replace( user.last_name, "'", "''" ) & "', " & _
                        " '" & replace( user.email, "'", "''" ) & "' " & _
                        user.id & ");"
                    conn.execute( SQL )    
                    set rs = conn.execute("SELECT userid FROM users _
					WHERE fb_userid=" & user.id )
                    
                    session("userid")=rs(0)
                    rs.close
                    set rs = nothing
                else
                    session("userid")=rs(0)
                    rs.close
                    set rs = nothing
                end if
            else
                response.write "Facebook Authentication Failed"
            end if
        
        end if    
        
    end if
    
    conn.close
    set conn = nothing
End function  

Points of Interest

I think the key point of interest is the routine for URLDecode from Flangy Development.

' An inverse to Server.URLEncode
function URLDecode(str)
    dim re
    set re = new RegExp

    str = Replace(str, "+", " ")
    
    re.Pattern = "%([0-9a-fA-F]{2})"
    re.Global = True
    URLDecode = re.Replace(str, GetRef("URLDecodeHex"))
end function

' Replacement function for the above
function URLDecodeHex(match, hex_digits, pos, source)
    URLDecodeHex = chr("&H" & hex_digits)
end function

I thought the use of GetRef to pass a function pointer to a regular expression was particularly clever.

Converting Pre 2012 Code

If you used this library before you know that 2012 update for facebook broke the library. As of Jan 16, 2012 I have updated the code to function with the new Facebook. In addition to fixing the code I took advantage of oAuth 2.0 which simplifies the setup somewhat. The tips below will outline the areas that need to change.

  1. Elimination of Facebook's Javascript Library
    You no longer need to reference the facebook library. Authentication is all handled with server-side code.
  2. Elimination of FB Markup
    The FB markup tag to enable Facebook has been replaced with a link to your authentication page. Be sure to include the FB_APP.ASP library in your login page. Now you create a link: <a href="myfbloginpage.asp">Use Facebook to Login</a> instead of the FB markup.
  3. oAuth 2.0
    To avoid future breakage of the code, I incorporated oAuth 2.0 mechanism of authentication. The above two changes are specifically part of this change.
  4. Scope moved to Server Side Variable
    The scope was moved to a server side variable (as a result of removing the FB markup). So you now need to set the scope in the FACEBOOK_SCOPE variable of the FB_APP.ASP page. In addition you need to set the FACEBOOK_REDIR_URL to the page on your website that handles facebook authentication. FACEBOOK_REDIR_URL is automatically created in V3.1 using the GetRedirURL() function. This allows any page with Facebook interaction to automatically login.

That should do the trick. I tested this out on a couple of my own sites and it worked well. However I can't test for every possible scenario. As such let me know if you experience problems with your site and I'll do my best to provide advice.

Related Articles

Classic ASP and Facebook Graph API

History

  • 16th July, 2010: Initial post
  • 16th January 2012: Revised for oAuth 2.0 (V3.0)
  • 16th January 2012: Posted bug fix (V3.0.1)
  • 25th January 2012: Version 3.1 - Several bug fixes, no longer need to set redirection URL. Cookie authentication token expires hourly forcing the fb_app.asp to request a new token.
  • 1st March 2012: Added a link to the new article.

License

This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)

About the Author

Larry Boeldt
Software Developer (Senior)
United States United States
Member
I've been in development since the late eighties. Although I've picked up many languages over the years and will likely pick up many more I have been a Microsoft BASIC programmer the whole time. Back in the early days it was on a Color Computer 3 writing articles for an enthusiast's magazine and developing solutions for color computer users. Now it is C#, VB.NET and (still) VBScript with all the fixins (ADO,XML,JSON,SQL etc...). Around 1996 I decided the internet was the way to go and dedicated myself to web development. I've been doing it ever since.
 
Two of my favorite projects are working for a little company called Nigrelli Systems and working with a team of brilliant Engineers to develop fully automated packaging systems for the food and beverage industry. The second is working on a "Burn Room" Nemschoff Chairs, again I was blessed with a team of people who knew their stuff. The burn room remains unique to this day because there are only a handfull of certified rooms in the US.
 
Bears, Beats, Battlestar Galactica

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Question?memberonurimamoglu11 May '13 - 5:43 
Microsoft VBScript runtime (0x800A01F4)
Variable is undefined: 'get_page_contents'
AnswerRe: ?memberLarry Boeldt11 May '13 - 9:38 
Hi,
 
Make sure you have this at the top of the page: <!-- #INCLUDE FILE="fb_app.asp" -->
 
Make sure the fb_app.asp is in the same folder as the page you are calling.
 
LB
QuestionError on 'user.id' fb_app.asp [modified]memberMember 811965316 Apr '13 - 1:01 
Hi everybody!
Was the "Object doesn't support this property or method: 'user.id'" problem solved by someone?
I tried to import your pages but after the login, the callback fails in that point Frown | :(
 
If I print the "resp" variabile (line 128) I read:
"resp={"error":{"message":"Error validating client secret.","type":"OAuthException","code":1}}"
 
Any suggestion?
 
I tried on IE and Mozilla Firefox but the result remains the same.
 
Best regards

modified 16 Apr '13 - 9:13.

AnswerRe: Error on 'user.id' fb_app.aspmemberLarry Boeldt19 Apr '13 - 17:32 
Hi,
 
The error message would indicate that you may not have set your application secret at the top of fb_app.asp.
GeneralMy vote of 5memberAlan Mustafa26 Mar '13 - 22:34 
This is what I've been looking for for the past many months. A quaity work in a slick way. Welldone.
GeneralRe: My vote of 5memberLarry Boeldt28 Mar '13 - 6:28 
Wow!! many thanks Alan.
 
There is a much improved version in terms of both ease of use and features available here: Classic ASP Integration with Facebook Websites Feature[^]
 
It goes beyond just the login capability it adds the ability to interact with friends lists and posting on walls. The graph API version is also much better at handling the sparsely populated data that graph api returns.
BugType mismatch: 'get_json_cookie'memberMattias Jacobsson13 Mar '13 - 4:47 
I get Type mismatch: 'get_json_cookie' when I try the code.
 
strJSON = get_json_cookie( request.cookies("access_token") ) ' this is a function in fb_app.asp
Set user = JSON.parse( strJSON ) ' this is the JSON object from JSON2.ASP
 

Please advice :=)
 
Mattias Jacobsson
GeneralRe: Type mismatch: 'get_json_cookie'memberLarry Boeldt28 Mar '13 - 6:32 
Hi Mattias,
 
Not sure what the cause of the error is, but the strJSON probably does not contain a string of text. I would start by observing what the strJSON variable contains. You might also try altering the user object creation as follows: Set user = JSON.parse( strJSON & "" )
 
That might give you an index is outside the bounds of the array or something similar, if you get that error then you know the strJSON object is an array. If you get to that point let me know we might have to dig deeper to find the right answer for you.
 
LB
QuestionThis does not log you out if you have logged out of facebook ... isn't this dangerous? [modified]memberleecabinet27 Feb '13 - 10:56 
If I Log in to the asp application with Facebook, and then I log out of Facebook I should no longer be authorised. Pia brought this up earlier but then suggested that it was solved by taking action when the user logs out of the asp application ... but in my opinion that's not enough.
 
There should be a check that the FB login status is "connected" in the equivalent of fb.asp before the call to get_page_contents(). Don't you agree?
 
I am trying to figure out how to access that value at the moment ... can you help? In the javascript SDK it FB.getLoginStatus ... is it even possible server side?

modified 27 Feb '13 - 17:11.

AnswerRe: This does not log you out if you have logged out of facebook ... isn't this dangerous?memberLarry Boeldt28 Mar '13 - 6:53 
Not sure how that would be implemented, you can't make an inquiry to Facebook unless you are logged in. I think somewhere there is a feature of the Facebook application setup where you can provide a "logout" page so that when user logs out of Facebook the Facebook application calls the specified URL to invoke the logout on your site. I suggest taking a look at the FB setup. If you figure out a solution please share here on CodeProject.
QuestionHow do I assign a user wall postmemberYusuf İşleyen3 Jan '13 - 1:09 
http://www.codeproject.com/Articles/94067/Classic-ASP-Integration-with-Facebook-Websites-Fea
 
How do these links point to the wall of the user after login as a user with classic asp can I post
QuestionUpload a PhotomemberMember 943439616 Sep '12 - 13:02 
Hi Larry, Your article is well documented and very useful.
I'm working in ASP Classic.
 
I'm already able to post a message and picture thumbnail on the User's Wall, but have not been able yet to upload a picture.
All examples I've found are using PHP-SDK Frown | :-(
Should I install Curl for IIS ?
GeneralThank you very much for such a great solutionmemberRakesh_Thakor17 Aug '12 - 3:43 
Hello,
 
Thank you very much for the solution, It helpful for me to implement Facebook login with existing Login / Register functionality. My Application is created with Classic ASP and MySQL.
 
Cheers!!!
 
Many Thanks,
 
Rakesh T.
QuestionGet the facebook id of the user logged into facebookmemberPia Palackathadom27 Jun '12 - 12:17 
Hi Larry,

I want to know if one of the following is possible:
 
1) Can I identify if the user has authorized my app even before redirecting to the Auth dialog? ie before the call to get_facebook_cookie()?
 
2) How can I get the facebook user Id of the user who is currently logged into facebook in my machine? This is outside the facebook auth process. Does facebook offer some api which I can use to read the fb cookie that is set when a user logs into facebook?
 
Thanks,
Pia
QuestionDoes not recognize that the user has logged out of facebookmemberPia Palackathadom27 Jun '12 - 5:21 
Hi Larry,

If you connect to my site through Facebook, and then log out of both Facebook and my site, pressing the Facebook button on our page re-authorizes the session as if the user was still logged in to Facebook. ie, the server side authentication does not identify that the user is logged out of facebook unless the user closes all browsers and tries again. I even tried switching to a different Facebook account (that was also associated with my site) and pressed the button again, but that did not resolve the situation; the user from the original session was logged in and not the one associated with the second Facebook account.
 
What do I need to do to identify that the user has logged out of facebook? I thought the redirect to the Auth dialog takes care of it. But looks like it does not. Please help.
 
Thanks,
Pia
 
Thanks,
Pia
AnswerRe: Does not recognize that the user has logged out of facebookmemberPia Palackathadom27 Jun '12 - 11:15 
I added this line of code when the user logs out of my site and that fixed the issue.
 
response.cookies("access_token")=""
 
Thanks,
Pia
Questionasp error : CDATEmemberkaan868618 Jun '12 - 12:17 
Microsoft VBScript runtime error '800a000d'
 
Type mismatch: 'CDate'
 
fb_app.asp, line 96
 

how can i fix?
AnswerRe: asp error : CDATEmemberLarry Boeldt28 Mar '13 - 7:03 
Hi,
 
You might have better luck with the Graph API article that I wrote:
[^] it does a better job of working with the sparse way that FB returns data elements.
 
When I browse code line 96 is blank. I'm guessing you might have added a few lines of code to the library. I believe the following is the code segment that is causing trouble:
 
 86      bExpired = false
 87      if CDate( request.cookies("token_expires") & "" ) < now() _
 88      and request.cookies("access_token")<>"" then
 89          bExpired = true
 90          response.cookies("access_token") = ""
 91          
 92      end if 
 
Assuming this is the segment that is failing, check the lines above this call, there should be code to fix a bad date value in the cookie:
 
 81      '' Set a default value for token expires
 82      if not isDate( request.cookies("token_expires") & "" ) then
 83          response.cookies("token_expires") = now() - 365
 84      end if

QuestionShowing the authorization dialog in a small pop-up windowmemberPia Palackathadom15 Jun '12 - 10:46 
I the file fb_app the line response.redirect( dialog_url )opens the Auhorization dialog. In other words, its just redirects to the dialog. I want the doalog to look like a small pop-up window instead of showing in the whole browser.
 
Please help.
 
Thanks,
Pia
AnswerRe: Showing the authorization dialog in a small pop-up windowmemberLarry Boeldt16 Jun '12 - 7:17 
Hi Pia, I'm not sure what you are proposing is possible without employing some trickery that might in the end make the solution less reliable. Perhaps a javascript to open the window then pass control back to the opener at the end of authentication might work but I'm hesitant to recommend that.
GeneralRe: Showing the authorization dialog in a small pop-up windowmemberPia Palackathadom18 Jun '12 - 11:15 
Hi Larry,
 
Thanks for your feedback. What I am trying to accomplish is i think a very common scenario. All the websites that I saw showed the authorization in a small pop-up window. For example, i want the Authorization dialog to show like in http://us.toluna.com. I read that i can pass display="popup" when i redirect to the suth dialog. But then all the subsequent pages are diaplayed in the same pop-up itself.
Need your input.
 
Thanks,
Pia
Questioninfinite redirection from facebook and my sitememberFrancesca Esposito3 Jun '12 - 16:39 
I copied and pasted this application on my site, I modified the variables "app_id" and "app_secret" with my codes, but the script is redirected back and forth between my site and facebook with firefox until the error "too many redirects
AnswerRe: infinite redirection from facebook and my sitememberLarry Boeldt16 Jun '12 - 7:22 
Hi Francesca, the most likely cause is that you are not accepting cookies or your browser is caching the page. Check your browser settings for cookies on the site that you are developing and also clear your cache. I hope this helps.
AnswerRe: infinite redirection from facebook and my sitememberTimoLehtinen3 Sep '12 - 22:04 
I have same problem. Tryed with many diffrent browsers. With diffrent cookie setting, with empty cache etc.
 
mayby I have missed something?
 
1. I have page where my normal login is. there is link to fb.asp
2. fb_app.aps I have replaced app_id and secret key to my own ones
 
Now it stays on infinite loop after login to facebook
GeneralRe: infinite redirection from facebook and my sitememberTimoLehtinen4 Sep '12 - 1:28 
I made litle hard coded modification to code:
 
			response.cookies("access_token") = token
			response.cookies("token_expires") = now()+0.04
			response.cookies("facebook_user_id") = user.id
			response.cookies("facebook_user_name") = user.name
response.Redirect("/testia.asp")
 
Hard coded redirect to my login page. now everyting works. I just have to dio some coding to my own login page.
GeneralRe: infinite redirection from facebook and my sitememberLarry Boeldt28 Mar '13 - 6:54 
Excellent! Thanks for sharing your solution.
QuestionIntegrating Facebook authentication mechanism with existing authentication mechanismmemberPia Palackathadom1 Jun '12 - 4:32 
I am completely new to classic asp.
Under the section "Using the Code" you have mentioned that "If you want to integrate the Facebook authentication mechanism with your existing authentication mechanism, you need to include code in the fb_main function of fb_app.asp".
 
1) Ii did not find fb_main function in fb_app.asp.
2) Also, i did not find myfacebookauthpage.asp in the downloaded file
3) Please let me know where I can find the facebook javascript library and how to include it.
 
Any help is appreciated.
 
Thanks
AnswerRe: Integrating Facebook authentication mechanism with existing authentication mechanismmemberLarry Boeldt5 Jun '12 - 19:35 
Hi Pia,
 
Rather than fb_main use the do_login example in the article. That should help you write the necessary integration steps.
 
As for attaining the fb_app.asp file, download the zip file from the link at the top of this article. Contained within are the fb.asp example page the json2.asp code library and the fb_app.asp application library.
 
You might also want to check out the revised code base as it is much more stable and includes some error handling along with being more object oriented.
 
Here's a link to the article:
[^]
GeneralRe: Integrating Facebook authentication mechanism with existing authentication mechanismmemberPia Palackathadom8 Jun '12 - 5:53 
Thanks Larry. I am now using your revised code. I have another question.
I want to know the code to put in my html to display the facebook login button on my classic asp page.
 
I read about a couple of ways like using javascript sdk and also xfbml. I am not sure which one to use. Also, in your code, you are using server side method of authentication. But the javascript sdk and xfbml methods of displaying the facebook login button are client side. What is the best method to display the button and still use your code for auhtentication?
 
Waiting on your reply.
 
Thanks,
Pia
AnswerRe: Integrating Facebook authentication mechanism with existing authentication mechanismmemberRakesh_Thakor17 Aug '12 - 3:46 
Hi Pie,
 
I have just implemented the required functionality with my Classic ASP application. You can see demo here http://www.turboigre.com/user_registration.asp[^]
 
Are you looking for the same features? Then I can help you.
 
Many Thanks,
 
Rakesh T.
Questionasp error [modified]memberleiti99917 May '12 - 22:59 
when calling your fb.asp (with my fb account information) i get the following error:
 
Object doesn't support this property or method: 'user.id'

/fbtest/fb_app.asp, line 142
 
json error message is: {"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}

modified 18 May '12 - 5:17.

AnswerRe: asp errormemberLarry Boeldt19 May '12 - 5:42 
It looks like your access token expired. Was this the first time you attempted to run the application?
 
You can force the fetch of a new access token by creating a page in your fb app (e.g. erase_token.asp) with the following code:
 
<%
response.cookies("access_token")=""
%>
 
Visit the page to clear your access token then try to re-visit fb.asp.
 
I hope this helps.
GeneralRe: asp errormemberleiti99920 May '12 - 19:47 
I am sorry, this solution doesn't work.
 
I tried deleting the cookie with your code, and by doing this in my browser. But when starting again, I get the same error message. ;-(
 
any ideas?
GeneralRe: asp error [modified]memberleiti99920 May '12 - 21:15 
new information: when calling the main page again (actualy works with client side facebook login), the user is logged in. So the correct information will be stored in the cookies ...
 
the error occours after login, when calling the page the second time (because of the redirect)
 
how can i avoid the asp error? would be nice, because I would like to chance fb login to your script Wink | ;-)
(problem also occours in your new version)

modified 21 May '12 - 3:57.

GeneralRe: asp errormemberLarry Boeldt21 May '12 - 18:36 
Hi, As far as I know you are the only person reporting this issue so far (others have reported putting it into production) so perhaps the issue is with either your server setup/configuration or perhaps a browser issue.
 
What Browser are you using?
What web server are you using?
What version of Windows?
 
Perhaps I can re-create the situation here then attempt to figure out what is happening.
GeneralRe: asp errormemberleiti99921 May '12 - 19:24 
Hello,
 
Browser: Chrome/Firefox/Firefox private mode
Webserver: IIS
Windows Version: I think 2008
 
I sent you an email with a link to production system.
GeneralRe: asp errormemberleiti99923 May '12 - 21:32 
could you reproduce it? did you get the mail with the links?
 
thx for support
GeneralRe: asp errormemberLarry Boeldt29 May '12 - 18:50 
Hi I didn't receive the links. Still unable to reproduce. Could you try sending again. Try sending via Facebook messaging.
SuggestionRe: asp errormemberkaan868618 Jun '12 - 12:09 
same problem i have
Microsoft VBScript runtime error '800a01b6'
 
Object doesn't support this property or method: 'user.first_name'
 
/fb.asp, line 48
 
how can i fix?
GeneralRe: asp errormemberMartin Geldart26 Jun '12 - 16:05 
I have same problem. Every now and then I get error "Object doesn't support this property or method: 'user.id'".
SuggestionJoin the new Classic ASP Developers page on Facebook! Pin [modified]memberLarry Boeldt7 Mar '12 - 16:20 
There used to be a page "Classic ASP for Die Hard Developers" group/page on Facebook. The group had no admin and eventually went stale. I created a new group/page with the hopes that we can rekindle the community under the new page. I'll vow to maintain it as long as I live (maybe longer Wink | ;) ).
 
Join the group and be a bigger part of the ASP community:
 
https://www.facebook.com/ClassicAspDevelopment[^]

modified 16 Jun '12 - 13:18.

QuestionId like to contact Larry Boeldt....memberElharter6 Mar '12 - 21:07 
Hey Larry,
 
id like to contact you over Facebook - but i am blocked currently for message@facebook. (damn).
 
Is it possible to contact you over email?
 
It would be great if you answer me, because i have some questions to your project.
 
Maybe you can do a paid work for me.
 
best regards from vienna
 

 
mike
AnswerRe: Id like to contact Larry Boeldt....memberLarry Boeldt7 Mar '12 - 16:19 
Hi Mike, You can find/friend me on Facebook if that works. Also join the new Facebook for ASP Developers page!
 
LB
NewsNew Article: Facebook Graph API for Classic ASPmemberLarry Boeldt1 Mar '12 - 16:57 
The next article provides a refactored version of this article's code plus some examples of interfacing with Graph API. Classic ASP and Facebook Graph API[^]
 
Give it a read and let me know how it goes for you!!!
QuestionHow to check if it is FB login?memberMember 845232625 Feb '12 - 4:30 
How can I check if it is FB login, before any action is taken? If I run fb.asp, it jumps to the FB login page if it is not login. But I want to check the login status first.
AnswerRe: How to check if it is FB login?memberLarry Boeldt1 Mar '12 - 16:55 
The Graph API doesn't provide a feature to check login (or at least I don't know of one).
Questionany suggestion BD integrate for New Versionmembermanusrugjoy22 Feb '12 - 20:16 
please suggest the new integration to database
AnswerRe: any suggestion BD integrate for New VersionmemberLarry Boeldt24 Feb '12 - 16:45 
Use the do_login example in the article and customize to fit your database. Call do_login after the set cookie = get_facebook_cookie() call.
QuestionFirefox NOT Maintaining Session State in an Iframemembermaefius15 Feb '12 - 15:10 
Hi - This article really helped me a ton! Thank you so much.
 
I have almost everything working, but then I noticed a problem when trying to load my application with Firefox. I've tracked it down to the fact that Firefox (at least my version) seems to not be allowing session variables in the iframe. This causes the line:
 
session("state") = enc.md5(newid()) '' CSRF protection 
 
to not get carried over to the redirect back from Facebook. So the next section (if request.querystring("state") = session("state") then ... ) never can run meaning the user can never log in.
 
Works fine in other browsers I tried. Is this something just on my end, or is this something with Firefox? Should I just take the CSRF protection out? Looks like it would work without it.
 
Thanks!!
AnswerRe: Firefox NOT Maintaining Session State in an IframememberLarry Boeldt16 Feb '12 - 14:25 
Since newid() creates a GUID which would be pretty hard to guess, you're probably all right just using the GUID without encryption. Alternately you could try keeping the encryption but stuffing the "state" into a cookie rather than the session.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 2 Mar 2012
Article Copyright 2010 by Larry Boeldt
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid