ASP.NET webpage as Facebook app

Hey guys,
I have another question with more down the line questions, but I suddenly realized I was struggling to just get my web page written in vb to be setup as a Facebook application.

I have seen many links with "how to", but they are mostly meant for php or if for it's written in C# and I'm struggling to get this converted to vb.

I believe another option for how to integrate your site is by using JS. But I'm not any good with JS, but if is not a good interface as it's mostly php for Facebook, then maybe JS is an alternative?

Does anyone have any good links, info, SDK, examples etc. for setting up a Facebook application in with VB as the language?

Who is Participating?

Improve company productivity with a Business Account.Sign Up

hesConnect With a Mentor Commented:
See here for the library
If you have what you want in C# code, you maybe want to convert it to VB.NET using a converter.
Another Very good Converter
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

VikingOnlineAuthor Commented:
I'll try to convert, but of course it might have been much easier to read and understand in vb.

So I get a few error messages while trying to follow this guide with C#

I loaded the facebook.dll (basically all the files given in the /bin directory). As far as I understand there are no issues with referencing a C# .dll from code.

I converted and used the following code:

Imports System
Imports System.Configuration
Imports System.Web
Imports System.Web.UI
Imports facebook
Imports System.Collections.Generic
Imports System.Xml.Linq

Partial Class _Default
    Inherits System.Web.UI.Page

    protected facebook.Components.FacebookService _fbService = new facebook.Components.FacebookService()

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        'Set the values for our Facebook service object's properties from our
        'web config file constants(specific to our application).        
        _fbService.ApplicationKey = ConfigurationManager.AppSettings["AppKey"]
        _fbService.Secret = ConfigurationManager.AppSettings["Secret"]
        _fbService.IsDesktopApplication = Convert.ToBoolean(ConfigurationManager.AppSettings["Desktop"])

            Dim sessionKey As String = TryCast(Session("facebook_session_key"), [String])
            Dim userId As String = TryCast(Session("facebook_userId"), [String])

            ' will will have the auth_token in the query params
            Dim authToken As String = Request.QueryString("auth_token")

            'We have already established a session on behalf of this user
            If Not [String].IsNullOrEmpty(sessionKey) Then
                _fbService.SessionKey = sessionKey

                _fbService.uid = Convert.ToInt64(userId)
                ' This will be executed when Facebook login redirects to our page
            ElseIf Not [String].IsNullOrEmpty(authToken) Then
                Session("facebook_session_key") = _fbService.SessionKey
                Session("facebook_userId") = _fbService.uid.ToString()
                Session("facebook_session_expires") = _fbService.SessionExpires

            End If
        Catch ex As Exception
            lblUserName.Text = ex.Message.ToString()
        End Try

    End Sub

Open in new window

1st error message:
      Imports facebook

"Namespace or type specified in the Imports 'facebook' doesn't caontain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases."

I would have thought that was an error message you would get if you did not reference the .dll, but I have done that. At least facebook.dll and facebook.dll.refresh and facebook.xml are all available in the \bin\ in the solution explorer.

2nd error message:

     protected facebook.Components.FacebookService _fbService = new facebook.Components.FacebookService()

"End of statement expected."
Not sure if this is just written wrong, or if once the import reference is working this will be OK.

3rd error message:

     _fbService.ApplicationKey = ConfigurationManager.AppSettings["AppKey"]

By _fbService:
"'_fbService' is not declared. It mayb e inaccessible due to its protection level."
This error message should be OK once the statement in error message 2 is OK. _fbService = new.......

By ["     before AppKey:
"Identifier expected"
This error I'm more unsure about. I thought I was referencing to the AppKey that is hidden inside the web.config file, but maybe I'm doing this wrongly.

Anyone that knows what I'm doing wrong here? If it's something I convert wrong, or if I do something fundamentally wrong, or if I should follow one of the other page suggestions for how to connect to Facebook?
VikingOnlineAuthor Commented:
Forgot to increase the points at the same time..
I thought someone would have a page reference and just post a in vb guide that I would read and follow through. But with so long without any Facebook link and trying to do conversion and getting error messages, this seems to be a much harder question than I first thought.
Hi Viking,
watch on on JS SDK. Do not be affraid.

There are some easy steps to do it instead of you:
Use their FBML tags. It will render the component you want. If you dont want to see any component, but just for example to post messages to a FB wall, you must setup the FB application for your domain and then generate access token. (Insert to your page FB login button, and catch the responsed info. You can easily see all necessary variables.)

Better will by, if you tell, what exactly you want to do in your app.
VikingOnlineAuthor Commented:
Thank you for your help and links!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.