Simple Tutorial for 2.0

Sep 5, 2008 at 5:10 AM
Edited Sep 6, 2008 at 2:32 AM
Hi, I posted this in another thread, but a lot of people will probably miss it.  I have posted a very quick and dirty tutorial for the basic framework you need using VB.Net (it can be very easily changed to work with c#).  Anyway, the tutorial is here for anyone who is interested:

Tutorial for Facebook Developer Toolkit on ebswift.com

I hope it is at least of some use to someone, it took me a number of days to figure it out given that none of the sample web code compiles yet.

Update: a download of a fully working project in c# is now provided at the tutorial page.
Sep 5, 2008 at 4:09 PM
Thanks for the post, I'll definitely be trying this... it looks very simple.  I created a topic earlier, asking about a friend invitation control.  It seems like most of the apps are using a standard invitation module/control, one would think something similar would be included in this toolkit.  I'd hate to have to write that page in PHP ... maybe I'm just missing something here.  Any ideas?
Sep 5, 2008 at 5:12 PM
Edited Sep 5, 2008 at 5:36 PM

Thanks for the post. I have been trying to get several of the various "tutorials" on the web to work using v2.0 (which I downloaded and installed today). I've have had some success with the v1.7 dlls but none with v2.0. I'm currently trying your example however I have converted it to C#. I've included my code below except for web.config which has been updated per your instructions.

I have three immediate questions that I'm hoping someone can answer:
1) I can't seem to create an equivalent reference to API in this line of code.
visitorInfo = Me.Master.API.users.getInfo(CType(Me.Master.API.uid, Long))

c#: visitorInfo = this.Master ???? Intellisense knows nothing of API

What am I missing?

2) When i run my code, I'm expecting to be initially presented with a facebook logon. This is not happening. Nothing happens except that a blank main.aspx is generated. With v1.7 code I receeived the fb logon but then that was because I explicitly coded that. My understanding from your post was that is being handled silently in the master page. I must be missing a reference or something. Any suggestions?


3) Lastly in your post you mentioned how you recompiled the API. Do I need to do that? I just put the following downloaded dlls in my BIN directory:
facebook.dll
facebook.web.dll
facebook.web.xml
facebook.web
Microsoft.XML.Schema.Link.dll


Thanks for any help.

FBMLMaster.aspx

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="FBMLMaster.master.cs" Inherits="FBMLSample.FBMLMaster" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head runat="server">

<
title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>

</head>

<body>

<form id="form1" runat="server">
<div>

 <asp:ContentPlaceHolder id="main_body" runat="server">
</asp:ContentPlaceHolder>

</div>

</form>

</body>

</html>

 

FBMLMaster.master.cs

using System;

using facebook.web;

 

namespace FBMLSample

{

    public partial class FBMLMaster : CanvasFBMLMasterPage 
    {

        protected void Page_Load(object sender, EventArgs e)

        {

 

        }

    }

 

}

 

Main.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/FBMLMaster.master" AutoEventWireup="true" CodeFile="main.aspx.cs" Inherits="main" %>
<%@ MasterType TypeName="FBMLSample.FBMLMaster" %>
<asp:Content ContentPlaceHolderID="main_body" Runat="Server">
<asp:Label ID="lblStuff" runat="server"></asp:Label>
</asp:Content>

 

Main.aspx.cs

using System;

using System.Web;

 

public partial class main : System.Web.UI.Page
{

    private facebook.Schema.user visitorInfo = new facebook.Schema.user();

 

    protected void Page_Load(object sender, EventArgs e)

    {

  visitorinfo = ??????

        lblStuff.Text = "Hello " + visitorInfo.first_name;

    }

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Sep 5, 2008 at 11:05 PM
Edited Sep 6, 2008 at 12:10 AM
@gmwade, in answer to your questions:

1) Check the namespace in the MasterType in main.aspx.  It might have to read as TypeName="FBMLMaster". edit: ignore that, maybe you have to hit compile on the aspx so it updates intellisense.  The new download sample has the reference working; it could potentially be to do with my re-compiled DLL which renames one of the API references but I am not sure.  My re-compiled dll is in the new download sample so you can easily compare.

2) The Facebook Developer Toolkit performs an FBML redirect in order to pass through the login - therefore it will only work on facebook.  When you run the page outside of facebook it will only show a blank page.  If you view the source you will see an fbml redirect that your server will not process.

3) Using c# you may not need to re-compile.  If you really want to re-compile you can use SharpDevelop, I just tested it with SharpDevelop 3, and it's capable of editing and compiling the toolkit.

I am in the process of making a downloadable zip of a c# version of the basic tutorial sourcecode which should be of some help.  I may even expand on it as I discover new tricks.  I just need to wait for the application to start responding - for some reason I occasionally need to wait for the web server to timeout after adding a new virtual directory website using VWD.
Sep 5, 2008 at 11:40 PM
I have updated the tutorial wiki page to add the c# project sourcecode download now.  I compiled that same source (of course, with my own attributes in web.config), setup an app in facebook, pointed to my project, and it is confirmed to be working, it's not just theoretical.
Sep 9, 2008 at 3:14 AM
I used your example and it worked great.  The only problem I had was I was unable to setup facebook to use http://localhost as my callback url.  Do you or anyone else know if this is this an FBML issue, I was able use localhost when using an iframe?
Sep 9, 2008 at 2:44 PM
Thanks for the tutorial, it's well layed out, and clearly written. If you do find out how to "modify that aspx form of mine to include a postback button" be sure to post a link to the follow-up article!
Sep 10, 2008 at 3:18 AM
Edited Sep 10, 2008 at 7:02 AM
I'm able to use form items when I do not use the master page inheritance but instead the page level inheritance and include a form runat="server".

Otherwise, I get the following error:
RegisterForEventValidation can only be called during Render();

If I set EnableEventValidation="false".  I get the error:
A page can have only one server_side Form tag.
<sigh>
Sep 10, 2008 at 9:26 AM
I can't compile so I'll just take a stab at it.

I believe the problem is occurring in CanvasFBMLMasterPage.cs lines 49-61:

public CanvasFBMLMasterPage()
        {
            PreRender += CanvasFBMLMasterPage_PreRender;
        }

        internal void CanvasFBMLMasterPage_PreRender(object sender, EventArgs e)
        {
            //var sb = new StringBuilder();
            var sw = new StringWriter();
            var htmlTW = new HtmlTextWriter(sw);
            this.RenderControl(htmlTW);
            System.Diagnostics.Debug.WriteLine(sw.ToString());
        }

This line is not in CanvasFBMLBasePage.cs and looks like it's trying to Render a control in the PreRender Event and needs moved to the Render Event or maybe removed?
Sep 10, 2008 at 10:44 AM
I had zero luck with a postback button.  I resorted to using a HTML post button along with HTML input fields and that serves my simple needs.  It would be nice if it could work via .Net though.

@test_dummy, as for the question about localhost, fbml is probably trying to access server-to-server, so localhost is potentially trying to point at a website called 'localhost' which will never point to your machine - instead you may need to use an I.P. address, which you might be able to do if you use a free dyndns address.  At dyndns you setup a 'web address' which points to your local I.P..  You then point your facebook app to youraddress.dyndnsaddress.com, where youraddress and dyndnsaddress are the location names you choose when you sign up.  I don't use dyndns for this because I have a .Net web host (which hosts ebswift.com), but I do use dyndns to give me an address for using RDP back to my home computer.  There is a client you install which notifies the dyndns site whenever your local I.P. address changes so it is pretty-much always available from the internet.  I hope that is of some assistance.

As for the runat=server forms I have not made any progress, though I tried it a number of ways.
Sep 10, 2008 at 8:21 PM
Something is wrong with the facebook.web.CanvasFBMLMasterPage class (which I posted my thoughts on above).  You're not going to be able to do a postback.  I was able to use .NET controls by doing the following, I didn't actually do a postback but I'm assuming at this point it will work.

Master Page
:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MyMaster.master.cs" Inherits="MyMaster" %>

<form id="form1" runat="server">
<asp:label runat="server" id="css" />
<asp:label runat="server" id="js" />
<asp:label runat="server" id="header" >
</asp:label>
<div id="main_body">
    <asp:ContentPlaceHolder ID="main_body" runat="server" />
</div>
</form>


PAGE:

<%@ Page Title="" Language="C#" MasterPageFile="~/MyMaster.master" AutoEventWireup="true" CodeFile="fb.aspx.cs" Inherits="fb" %>

<asp:Content ID="Content2" ContentPlaceHolderID="main_body" Runat="Server">
    testing
   
<asp:Label ID="lblStuff" runat="server"></asp:Label><br />

<asp:Label ID="lblTest" runat="server"></asp:Label><br />
<asp:TextBox id="txt22" runat="server" />
</asp:Content>

Page CodeBehind:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class fb : facebook.web.CanvasFBMLBasePage
{
    private facebook.Schema.user visitorInfo = new facebook.Schema.user();

    protected void Page_Load(object sender, EventArgs e)
    {
        visitorInfo = this.API.users.getInfo(this.API.uid);

        lblStuff.Text = "Hello " + visitorInfo.first_name + "!";
        lblTest.Text = "Test";
    }
}


Sep 10, 2008 at 8:43 PM
@test_dummy, thanks for your post, I'll take a look into that.  In the meantime, above you mentioned you can't compile the FDT code, so I've made another mini-tutorial on getting SharpDevelop set up so that you can edit and compile the FDT solution.  The new tutorial is linked off my FDT getting stated tutorial, under the API Change heading.
Sep 11, 2008 at 11:38 AM
Edited Sep 11, 2008 at 12:48 PM
Hi guys,I've been playing with the postback thing, pretty stumped here too.

If I include the <form> tags in a content page like this:

<asp:Content ID="Content1" ContentPlaceHolderID="main_body" runat="server">                   
<form runat="server" id="form1">                   
<asp:Button ID="bSave" runat="server" Text="Save" onclick="bSave_Click"/> 
</form>
</asp:Content>

I get an InvalidOperationException: "RegisterForEventValidation can only be called during Render()"

However, removing the form tags gives me "'Button' must be placed inside a form tag with runat=server"

In the CanvasFBMLMasterPage.cs file, the 

this.RenderControl(htmlTW);

method call in 

internal void CanvasFBMLMasterPage_PreRender(object sender, EventArgs e) 

May be in the wrong place. I think it needs to be in a render event as opposed to prerender. Not quite sure what a good work around for that would be though... So I think I agree with your thoughts test_dummy. Incidentally, did you manage to do a postback with the code you provided?
Sep 11, 2008 at 1:03 PM
Edited Sep 11, 2008 at 2:24 PM
Succesful postback achieved:

I opened the  facebook.web project in VS 2008 (express), added the xml.schema.linq reference from the root bin folder.

edited this code in CanvasFBMLMasterPage.cs:

internal void CanvasFBMLMasterPage_PreRender(object sender, EventArgs e)
        {
            ////var sb = new StringBuilder();
            //var sw = new StringWriter();
            //var htmlTW = new HtmlTextWriter(sw);
            //this.RenderControl(htmlTW);
            //System.Diagnostics.Debug.WriteLine(sw.ToString());
        }

(That's right.. I commented it all out! Also, it would perhaps be more elegant to remove the line that calls this function)

Rebuilt project, and copied new facebook.web dll to my project to update the reference.

for the record I've got version 22331 of the toolkit, I found a link in another thread somewhere.

Now in a content page using the masterpage that inherits from CanvasFBMLMasterPage, I can use <form> tags:

<asp:Content ID="Content1" ContentPlaceHolderID="main_body" runat="server">
<form id="form1" runat="server">
<asp:radiobuttonlist id="rblStuff" runat="server">
                    <asp:ListItem Text="Thing" Value="1"></asp:ListItem>
</asp:radiobuttonlist>
 <asp:Button ID="bSave" runat="server" Text="Save" onclick="bSave_Click"/>
</form>
</asp:Content>

Works just fine. I'm able to call the bSave_Click method, save and retrieve data from my server etc. Obviously a nasty hack, no idea what doing this may break, but looking at it, they just seem to be empty objects being passed to the RenderControl method anyway.

Sep 14, 2008 at 10:43 PM

Sweet work Zeus, I was finally able to get a button to postback properly.  It shouldn't have taken that long, but for some reason, even though the compile time matched on the modified facebook.web.dll after I modified & re-compiled, it seems it was still using the old version.  I have an onclick event working nicely, writing text back to a label for a test.  When I get the chance I will update the tutorial and credit it to you and test_dummy.

It's certainly nicer than using HTML forms.

Sep 15, 2008 at 12:39 PM
Thanks, I'm just glad it worked for you too! It's certainly somthing I'd like to see ammended to the source code, but I'm not really comfortable with appending the code with such a hack... I'll keep an eye out for your next tutorial, I look forward to seeing you tackle publishing to userfeeds, as I think they're broke, (see thread).
Sep 16, 2008 at 9:29 AM
Well, one step at a time, I need to apply some finishing touches to my app, then I can do more work on the tutorial.  I would only hope my tutorial becomes redundant as the sample code starts working with the new FDT.  I released my app to facebook this morning, it's called 'SmugFoto'.  It's an app to display photo galleries from a SmugMug account.  There is a free trial period available from SmugMug, it's not a free service in itself, however SmugFoto is free to use for SmugMug users.
Sep 16, 2008 at 1:32 PM
Its good to see more people are getting their heads around how to develop FB apps using v2.0. Just wondering though if anyone had anyluck using the webcontrols in v2.0? I seem to be running into a serialization problem:

Type 'Microsoft.Xml.Schema.Linq.XTypedList`1[[facebook.Schema.user, facebook, Version=2.0.3142.23334, Culture=neutral, PublicKeyToken=null]]' 
in Assembly 'Microsoft.Xml.Schema.Linq, Version=0.10.1000.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

I believe the culprit is this line:

friendList1.Friends = MyBase.API.friends.getUserObjects
I'm inheritting from CanvasFBMLBasePage so the MyBase is referring to the mentioned.

Thanks,
Sep 17, 2008 at 10:21 AM
you might want to give this a try:
friendList1.Friends = MyBase.API.friends.get()

It should return an IList<long> of the friends userID's. Although I must admit to not having used any of the webcontrols in an version of this toolkit, so I'm not sure what object friendList1.Friends is expecting I'm afraid.

That said I've successfully used FBML inviter like so:

C# :

                string UsersToExclude = string.Empty;
                IList<long> AppUserFriends = this.Master.API.friends.getAppUsers();

                foreach (long L in AppUserFriends)
                {
                    UsersToExclude += L.ToString() + ",";
                }
               
                CURRENT_USER_FRIENDS = UsersToExclude.TrimEnd(',');
                APP_URL= "http://www.apps.facebook.com/" + ConfigurationManager.AppSettings["Suffix"];


In your HTML somewhere :

<fb:request-form
    type="[AppName]"
    content="Something <fb:req-choice url='<%=APP_URL%>' label='Check Out AppName...'/>"
    action="http://apps.facebook.com/[APPNAME]/"
    invite="true">

    <fb:multi-friend-selector max="20"
    actiontext="Here are your friends who don't have [AppName]"
    showborder="true" rows="5"
    exclude_ids="<%=CURRENT_USER_FRIENDS%>"
    />
</fb:request-form>


But that's probably not much help to you. sorry :)

urgh, why's the formating on codeplex so horrid?
Sep 18, 2008 at 2:55 AM
haha..thats fine. Thanks for your help.

format wise though, you should use the html tags <code></code> which would make it look a tad nicer.;)

friendList1.Friends expects IList <schema.user> . And since MyBase.API.friends.get() returns IList<long>, I am afraid that it wont work. That is why I used

MyBase.API.friends.getUserObjects
which actually returns IList<schema.user> which seems correct, but returns the exception mentioned above.


Sep 29, 2008 at 7:59 AM
Hi,

Have any of you had problems with facebook not liking the line which starts with <%@Page Language?

Here is my default.aspx which works fine if you remove the first line to remove the reference to the default.aspx.cs codefile.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="default.aspx.cs" Inherits="_Default" %>
<form>
<div>
     <fb:dashboard>
           <fb:action href="#">Link 1</fb:action>
           <fb:action href="#">Link 2</fb:action> 

           <fb:action href="#">Link 3</fb:action>
           <fb:help href="#">Help Me!</fb:help>
        </fb:dashboard>
        </div>
<br />
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
<div>
                 <fb:friend-selector idname="txtSelectedFriend" />
</div>
</form>


Does anyone know how to get around this?

I look forward to any replies.

Thanks,

Chris



Oct 1, 2008 at 8:36 AM
Edited Oct 1, 2008 at 9:04 AM
Okay, i know it's late and I haven't been able to get to this project for the past two weeks but I'm having trouble getting the current App User Email.

I need the current user's information.... User Id, First Name, Last Name & email (user name).

I was able to do the following

            facebook.Schema.user visitorInfo = new facebook.Schema.user();
            visitorInfo = this.API.users.getInfo(this.API.uid);

However I do not see how to get the user email address.  It would be a huge blow to my app, if i can not obtain the users email address.

In regards to chris_edgar: You have to start an asp.net page with: <%@Page Language ... There is no workaround.  By that I mean, the problem is something else.  If you view the source within your app on FaceBook, you can get more information about the error occurring on your page (you have to be logged-in with the developer's account and the error is commented out in the HTML source).
Oct 1, 2008 at 2:34 PM
You've never been able to get the user's email address (nor ever will) as it just opens the whole thing up to spammers.

I don't email my users but there must be a method in there somewhere to do this for you.
Oct 2, 2008 at 12:16 AM
Yeah, spammers suck!  I don't want to email my users, I just need their email address... as I wanted to use their email to look up information about them with another service... I can use name but there are a lot of people with the same name so it would not be nearly as user friendly.  This is what I found on the subject -- it makes it sound like you have access to the emails of anyone that adds your application.

http://wiki.developers.facebook.com/index.php/Users.getInfo
email_hashes is an array containing a set of confirmed email hashes for the user. Emails are registered via the connect.registerUsers API call and are only confirmed when the user adds your application. The format of each email hash is the crc32 and md5 hashes of the email address combined with an underscore (_).
Oct 2, 2008 at 8:17 AM
Edited Oct 2, 2008 at 8:19 AM
-
Oct 2, 2008 at 8:20 AM
Regarding the FBML error I am receiving, I have looked at the html source and I see " <!--Rendering the page using the following FBML retrieved from http://abc.com/
You are seeing this because you are a developer of the application and this information may be useful to you in debugging.  The FBML will not be shown to other users visiting this page. (dashes were replaced with underscores):" but no commented out FBML code is shown?
Oct 3, 2008 at 9:34 PM
Is there somewhere I can get the new dlls- especially with the master page issues worked out? I don't have VS and can't compile projects.
Thanks!

Oct 3, 2008 at 11:54 PM
Edited Oct 3, 2008 at 11:56 PM
@joejoej..47  I have updated the TestFDT.zip download (linked off the tutorial in the first post) to include verified fixes.

These are my internal notes of my changes based on the work of others in this thread & forum:

--------------------------
When the source has been reverted, change:
public API API
to
public API myAPI
in:
Source\Facebook.web\ CanvasFBMLBasePage.cs

Change CanvasFBMLBasePage.cs, change private bool _requireLogin = false;
               Comment out the contents of  internal void CanvasFBMLMasterPage_PreRender

Recompile.
--------------------------

I hadn't mentioned _requireLogin here previously, but what I've done is defaulted it to false.  This removes the need for visitors to add the application before it will operate.  Basically any operation involving info about the user requires a login, but for my purposes, I don't have that requirement - visitors can view my application on other people's profiles anonymously - being a photo viewing application, that's fairly important, otherwise visitors would be scared off.

If you are keen on compiling for yourself, see the end of my tutorial for information about getting SharpDevelop up and running.  It is very, very easy to get running and is very similar in feel to VS2008, just not quite there for debugging yet last time I looked (though I need to update the codebase and see if they have fixed that recently).  As a poor-man's Visual Studio, SharpDevelop will produce projects of exactly the same quality as Visual Studio, and you can mix c# & vb.net in the same solution and compile multiple projects under one master solution - none of the limitations of express.  SharpDevelop cannot be used for web development yet, though that may change.  VS web developer does fine for this, just make all your class libraries under SharpDevelop.

edit: you can't post on this forum using google chrome
Oct 4, 2008 at 12:29 AM
Thanks! I'll check it out
Oct 4, 2008 at 11:57 PM
Edited Oct 5, 2008 at 2:11 AM
I found an example of updating a user feed in another thread:

Dictionary<string, string> bodyDictionary = new Dictionary<string, string>();
bodyDictionary.Add("trouser_style", "parachute pants");

// Add an image to the details
Collection<feed_image> feedImages = new Collection<feed_image>();
feedImages.Add(new feed_image("http://www.mysite.com/images/large.gif", "http://apps.facebook.com/myapp"));

// Publish this
this.API.feed.publishTemplatizedAction("{actor} did something",
 null,
"{actor} loves to wear {trouser_style}.",
bodyDictionary,
"<br/>Thanks for reading my footer",
0,
feedImages,
 null);

Oct 6, 2008 at 10:54 AM
Edited Oct 6, 2008 at 11:22 AM
Facebook hates app developers, I lost a full day of app adding because the FDT had the 'new.' facebook address which now suddenly broke.  Surely an email saying 'hey, your application will break tomorrow' would be nice.  Anyway, here is the updated internal readme I made on the FDT compiling (I've also replaced the compiled DLL's in my tutorial linked in the first post):

 

When the source has been reverted, change:
  public API API
to
  public API myAPI
in:
Source\Facebook.web\CanvasFBMLBasePage.cs

Change CanvasFBMLBasePage.cs, change private bool _requireLogin = false;
               Comment out the contents of  internal void CanvasFBMLMasterPage_PreRender

Change CanvasFBMLMasterPage.cs, change private bool _requireLogin = false;

in:
Source\Facebook.web\CanvasFBMLBasePage.cs
Change new.facebook.com
to
facebook.com

Recompile.

edit, I stuffed up, the _requireLogin variable also needs to be changed to false in CanvasFBMLMasterPage.cs.

Oct 6, 2008 at 5:15 PM
Hi guys,

is there a tutorial around using the 2.0 toolkit that uses multiple pages as seem to be getting redirected back the default.aspx page when click to another page

Thanks

Lee
Oct 6, 2008 at 10:23 PM
Hi there Lee.  I didn't use any magic getting page->page working, it just works using the < a tags.  I don't use any path or web address in the page hyperlink, I just use something like:

< a href="nextpage.aspx" >click me< / a >

When I get time I will update my tutorial; in the meantime I've been putting out fires caused by facebook's idiotic change methodology.  They won't beat me though.
Oct 7, 2008 at 4:43 PM
Glad to see your example and know other .net coders are out there trying to manifest some facebook action.

At first I got the error "(FBO~OK2.DLL) The located assembly's manifest definition does not match the assembly reference". I put in the 2.0 copy of the dll from sourceforge (which was oddly a different size than the one provided in the example) and then tried again and got the same error. I copied your dll back over and this time it told me the smugmug references and the Vistadb refs in the web.config were no good, so i nixed those.

Then I got an object reference error to the sample codebehind for main.aspx which I fixed as follows:

visitorInfo = this.Master.API.users.getInfo(
this.Master.API.uid);
        if (visitorInfo != null)
        {
            lblStuff.Text = "Hello " + visitorInfo.first_name + "!";
        }

but it's null because something isn't happening properly. I get no value returned where there should be one. Can anyone assist?

Thanks in advance, this forum has been really enlightening. -jesse
Oct 7, 2008 at 10:27 PM
Lee, I get the same thing. It looks like a new session is being created on my web server for the other page.
So, there's no FB info in the session. Therefore, the toolkit will end up calling RedirectToLogin() in EstablishSession(). Back to the default page you go.
The auth_token is not being put in the url either.  I'm not sure the toolkit can help here, but there are lot's of features I don't know about.

NOTE: If you are debugging, the links will probably work - for some short amount of time. Eventually, they won't.
Or, if you publish your web site and try it on another machine, it'll show this behavior.
Oct 8, 2008 at 1:29 AM
I'm currently updating the tutorial to fix a couple of bugs and demonstrate more functionality like postback buttons, and configurable anonymous/forced login app browsing.

To fix the visitorinfo being null (for those using the latest version of the tutorial DLL's) you need to add:

 

this.RequireLogin = true;

 

 

this.Page_Init(null, null);

before the line: visitorInfo = this.Master.API.users.getInfo(...)

By default with my modded dll, RequireLogin is false, so when you want to get user info you need to set requirelogin to true.  If requirelogin is true by default then it is impossible to allow anonymous visitors to the application.

 

Oct 9, 2008 at 4:22 PM
Hi,

I'm not sure how to fix the issue as nothing ever gets passed to the session variables. I am completly confused on the authentication process and read anything relating to it.

I was using the iframecanvas page then try the masteriframecanvas page, they neither but all with the same issue. Is there a iframe based application in the community using the version 2 toolkit. Or if I post mine tried out could someone have a look and try to explain whats happening?

Thanks

Lee
Oct 9, 2008 at 9:58 PM
Hi Lee, I think everyone is confused about the authentication process.  Maybe some of the fixes we have come up with for the fbmlcanvass can be transferred over to iframe?  I'm still working on my tutorial app, and now have a good idea for a working demo that shouldn't take me too long to get up and running.  Sadly though, this work is quite possibly being done in parallel by the FDT developers.
Oct 10, 2008 at 2:44 PM
Hi,

Should I not use the iframecanvas and if so, whats a way around this. or is 1.7 better to use than 2 at moment

Lee
Oct 20, 2008 at 8:56 PM
Edited Oct 20, 2008 at 8:58 PM
I'm afraid I can't help with iframecanvas questions because I haven't gone there.

In the meantime, I've packaged up a V2 of the tutorial application which now includes publishUserAction in the dll.  I'd really appreciate it if someone could contribute how to actually make the user feeds work - I think I have gone a long way to implementing it but I believe I have got the fundamentals wrong - I don't think you're supposed to register a template bundle every time.

Anyway, the V2 tutorial is incomplete, but it does demonstrate having anonymous visitors to the application (by way of my default setting of requireLogin=false) and allowing people to install it to their profile, as well as simple status recording via url parameters.  It is very very basic, but I will progressively add to it.  At this stage there is probably some new stuff that people can build from.

Download the new tutorial from here:

http://www.ebswift.com/Wiki/wikka.php?wakka=FacebookDeveloperToolkit

It is the TestFDTV2 experimental download.  This zip also includes a patch which details every change made to the FDT source (which you can also apply to your own source if you like). Apart from one or two minor changes of my own, most work going into the patch is from forum members here.
Oct 21, 2008 at 5:47 AM
@ebswift

I think I can shed some light on the template bundles. What I have done can only take you so far...
I have been feverishly clicking around the facebook site for a few weeks now and I've found the templates hidden away
on facebook's tools page -> http://developers.facebook.com/tools.php

Once your logged in you will see 4 tabs on this page.
'Feed Preview Console' is where you should start. It looks to me that they assume your templates are for the most part
static with FBML pulling the dynamic user content. You create the different feed types (one line, short story, full story)
one you have them the way you want them you click Preview and If they look alright - Validate. As far as I can tell this then registers the template and spits out
your template bundle ID. Now I don't know what you've done with that in the API, but I'm assuming that I can then tell facebook to send a template ID to a user's feed
something like profile.publishUserAction(uid, templatebundleid), and that will have the desired effect.
I imagine for the most part the feeds would be sort of static...

Mine currently is something like:
{*actor*} has updated <a href="http://apps.facebook.com/MyApp">My App</a>

The 'Registered Templates Console' is where you can administer your templates.
It only seems that you can turn them on or off from here...

I *hope* that I am helping someone out there, it would be nice to feel like my meandering has paid off in some way.
Oct 21, 2008 at 6:18 AM
@abend, that is highly relevant stuff.  I had seen mention of the templates page before but at the time I was struggling just to get code & datatypes right.

Now it's starting to make sense.  The stuff in the API is simply the code posted to this forum that people said was working for them (combination of posts). 
You will see the method in the .patch file in the tutorial zip file (linked in the first thread post).  It *appears* to me that you register the template id's from a page
in your app, but you only register your templates ONCE and take note of the template id.  It seems you are right about things being static which will probably
limit the usefulness unless there are some kind of placholder tags that you can send variables into.

From here I will create a registertemplates page to define specific templates for the tutorial and place a flag so the page can't be accidentally run again.

This facebook API does not cease to amaze me.  I truly think they want to do away with amateur developers by pure complexity.
Nov 24, 2009 at 8:11 PM

Hello.  I've been trying to find the answer to my issue similar to this one...My problem is, that when I run locally through the debugger, postback's work fine, but when I try to use the apps.facebook.com/myapp address to connect to my application, postbacks do not work.

 

I have posted another forum topic with code attached that can be viewed at http://facebooktoolkit.codeplex.com/Thread/View.aspx?ThreadId=76039

 

I'm wondering if it's my facebook settings? or if it's the SDK. I would also love to know how to fix this. I have officially lost a day now of development due to this problem.

 

thanks for any help