Jump to content


Facebook SDK questions - authentication and app flow

facebook authentication

  • Please log in to reply
No replies to this topic

#1 Grandioso

  • Members
  • PipPipPip
  • Advanced Member
  • 98 posts
  • LocationLondon

Posted 11 February 2013 - 01:08 PM

I'm building my first ever page tab app for a facebook fan page. It's mostly static HTML with a gallery of user submitted images. The users will be able to vote for the images and the picture with the most votes wins. SImple enough, but I'm struggling here.

I'm currently facing 2 problems - the first one is related to authentication inside the app and the other to app flow.

1. authentication

In order to know who uploaded the picture, I need to get some unique user info + name. I found out that this is impossible without user authentication, so I'm trying to get the user to authenticate and let me use their ID/name.

I created a login link using the getLoginUrl method of the php SDK. This login link works fine when used outside the context of facebook, but doesn't do anything when clicked inside the page tab.

How else do I get the desired user data ?

2. app flow

I'm trying to split the app into 3 main modules for now - main page, pre-like and upload form. Which one is displayed would be determined by a post variable.
My index page looks like this:

include( 'head.php' ); 

if ( $is_liked )
switch( $_GET['c'] ) 
case 'upload' :
include( 'pages/upload-form.php' );
default : 
include( 'pages/main.php' );
} else 
include( 'pages/pre-like.php' );

include( 'foot.php' ); 
The head file initializes the FB Object and creates a variable to say if the user like the page or not.

$signed_requrest = $fb->getSignedRequest();
$is_liked = $signed_requrest['page']['liked'];

This works fine, but when I'm on some other page (with a URL parameter), then the FB object will not be created correctly, therefore I'm not able to get the 'liked' state of the current user. Does anyone have any idea what's wrong with this ?

I hope someone will be able to help me, as the documentation is not too clear about these things...
1. Thou shalt always upgrade thy browser.
2. Thou shalt not use Internet Explorer.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users