setFBML for any user using infinite session

Jul 3, 2007 at 7:03 PM
Edited Jul 3, 2007 at 7:04 PM
I am trying to call the setFBML function using the infinite session to update the profile page for any user. To do so, I am trying to short circuit the creation of the FacebookService item using the infinite session and the UserID of the user I want to edit.

If i pass bInfiniteSession = True, then I assign the infinite session from config (which holds the infinite session key) and the userID I passed through to the function.

It successfully logs me in, but when I call the setFBML function, nothing changes on the profile page. However, the setFBML function does work if I call this page while logged in as a user (without doing the short cutting - i.e. by setting bInfiniteSession = False and logging in normally).

My code to create the service variable is as follows:

Private Sub FBLogin(ByVal bInfiniteSession As Boolean, _
ByVal iFacebookID As Int64)
service = New Facebook.Components.FacebookService()
service.ApplicationKey = <<ApplicationKey>>
service.Secret = <<SecretKey>>
service.IsDesktopApplication = False

Dim sessionKey As String
Dim userId As String
sessionKey = TryCast(context.Session("Facebooksessionkey"), String)
userId = TryCast(context.Session("Facebook_userId"), String)

' When the user uses the Facebook login page, the redirect back here will will have the auth_token in the query params
Dim authToken As String = context.Request("auth_token")

Dim qStringSessionKey As String
Dim qStringUserID As String
Dim qStringSessionExpires As String
qStringSessionKey = context.Request("fbsigsession_key")
qStringUserID = context.Request("fbsiguser")
qStringSessionExpires = context.Request("fbsigexpires")

If bInfiniteSession Then
Dim config As Config
config = New Config()
service.SessionKey = config.sFacebookSessionKey
service.UserId = iFacebookID

ElseIf (Not String.IsNullOrEmpty(sessionKey)) Then
service.SessionKey = sessionKey
service.UserId = userId
' This will be executed when Facebook login redirects to our page
ElseIf (Not String.IsNullOrEmpty(authToken)) Then
context.Session("Facebooksessionkey") = service.SessionKey
context.Session("Facebook_userId") = service.UserId
context.Session("Facebooksessionexpires") = service.SessionExpires
ElseIf Not (String.IsNullOrEmpty(qStringSessionKey) _
Or String.IsNullOrEmpty(qStringUserID) _
Or String.IsNullOrEmpty(qStringSessionExpires)) Then

service.SessionKey = qStringSessionKey
service.UserId = qStringUserID
context.Response.Redirect("" & service.ApplicationKey & "&v=1.0")
End If
End Sub
Jul 3, 2007 at 7:10 PM
In your test, are you logging in as the same user when you do an interactive login and when you use the infinite session?

I will try to reproduce.

Can you trace when you login interactively and see that you are using the same session and userId in both cases?
Jul 3, 2007 at 8:05 PM
I just tried to write to my profile using an infinite session. (Instead of logging in interactively.) And it seems to work fine.

Can you let me know if you are trying this for the same account (interactively and with infinite sessions)

Jul 3, 2007 at 8:14 PM
I think what I'm trying to do isn't possible in the current version (1.1). It does work if I use the infinite session/userID of UserA, but if I want to use the infinite session of UserA to call setFBML for UserB, I think I have to do it manually (make the api call myself, rather than through the toolkit). I was trying to see if this was a workaround that would let me make the setFBML call on one user using another's session key, but it doesn't appear to be.

rpowers119 wrote:
I just tried to write to my profile using an infinite session. (Instead of logging in interactively.) And it seems to work fine.

Can you let me know if you are trying this for the same account (interactively and with infinite sessions)


Jul 3, 2007 at 8:19 PM
Hmmm. I am adding an override today for SetFBML that takes the optional uid of the user to set it for.

Perhaps that will help. We will posting a new Version 1.2 later this afternoon with this change.
Jul 7, 2007 at 6:01 PM
Edited Jul 7, 2007 at 6:04 PM
I am having the same problem, using ver 1.2 I have finished the application just to find out that to update the profile's FBML each user will have to go to my canvas page. How do I setup a single update for all users?
Jul 9, 2007 at 10:01 PM
I sent this in email. Hope it helped.
You can call setfbml and pass in a user.

So you'd need to have all of your facebook users stored somewhere and have a job establish a session with your app. (using your own established infinite session) you could then call setfbml for any/all od your users.
Jul 9, 2007 at 10:39 PM
Thanks, I did build it according to your discription and it is working great.
For the sake of future searchs here are my steps I followed to allow me to be able to update all App users profiles at once:
1. The post install URL takes the user to a page that checks if the userId is already in my DB and adds the userId if not.
2. Then I use a <fb:redirect> to go to the main application page, then main app page calls SetFBML for this user.
3. To update all users profiles, I created a 3rd page that onload loops thru all userIds in the DB and runs SetFBML for each Id.
4. I didn't build it yet but there is a remove URL that can be used to remove userIds from the DB.
Note: I am not sure how scalable is my updater (3), I assume when you get the a certain amount of users the page will timeout before running all SetFBML calls. When I get there I will probably break it into batches.
Sep 9, 2007 at 12:21 AM
Hello there,

I found your post quite helpful since I have the exact same problem.
I am trying to update the profile for the users according to the correct time of the day and location.
It is quite straight forward, but the fact the user has to go to the canvas page to do it so is annoying me.
Is it possible for you to give me a bit of the code that you used on your 3rd page that onload loops thru all userIDs and then run setFBML for each ID?
I understand how it is suposed to work. Are you using profileSetFBML?
Sep 9, 2007 at 12:28 AM
Another thing which I want to know is if I need an infinite session for it and if so how do I use it. I really appreciate your help and if you are in london you can count on a pint.

Thank you,

Sep 12, 2007 at 5:11 AM
Login to your app as you. And click the save session info checkbox.

After login, store your facebook user id, secret, sessionkey and api. NExt time, store all 4 properties on the facebookService prior to making any calls.
Sep 29, 2007 at 8:14 PM
my application is already added to my account. to get to my application, i loging to facebook and click on the left nav link. the quetion is where is the checkbox "save session info checkbox". or how do i get to that checkbox

secret and api, i believe that is the one we get from facebook when we add new application.