views:

786

answers:

4

Hi, I'm really struggling to make facebook connection working for my system. What I want to do :

  1. When the user is not yet registered on facebook :
    1. Fetch some user profile fields into my database (ideqally via my registration page already working for non facebook users)
    2. Log the user into my website
    3. Redirect the user into my homepage
  2. What I've done so far :
    • Set up the application in FB
    • Add the Facebook class from the github website and integrate some code to make it working
    • Add additionnal paremeters to login/register facebook link.

I'm struggling to redirect the user after authorizing, to my register page (register/?facebook). The "Post-Authorize Redirect URL" field doesn't seem to work properly, I maybe do not fill the right field?

My other question is, if my registration page uses a redirection show (index.php redirect to register.php), do the information given by facebook through the $_POST method would be available in the register.php page ? I don't think so, do you ?


Regards,
Nicolas.

A: 

Don't send data to register.php via _POST. Use the facebook php SDK's methods to retrieve the data from current logged in user's session.

zerkms
Hi,I'm already doing that, a var_dump() shows me that all data I want are retrieved, but I'd like facebook to redirect me to my register.php page where, if a facebook user is connected, the form is auto sent and then create the user in my database.And the problem is that whatever I put in whatever fb application settings pages, it won't send me to my registration page.
Nicolas
"but I'd like facebook to redirect me to my register.php page where, if a facebook user is connected, the form is auto sent" - this is a bad idea. i already said what is common way. "it won't send me to my registration page" and how this related to question? don't mix a lot of issues in one question, decompose them into different troubles.
zerkms
A bad idea? Then what do you suggest? In the php-sdk there isn't anything about inserting data into our own db. It's all about retrieving and displaying information (which DOES work in my case as I said before). Instead of auto-sending my form I think I would like to pre-filled the form. Sounds better to you? Anyway in this case, because of the redirect (I think) the facebook logged user is logged off in the next page =/
Nicolas
%) you have conceptual troubles on how to ask questions and to program. "It's all about retrieving and displaying information". so? just replace "echo" with "mysql_query" and insert data in database. "Anyway in this case, because of the redirect (I think) the facebook logged user is logged off" - this is another issue. you did something wrong - redirect should not cause the logging off.
zerkms
A: 

to solve redirect issue check this question

Ji
+1  A: 

I finally managed to get all of this working, so if you're still struggling here is what I've done :

  1. Concerning my redirect problem: the facebook php-sdk class redirection page ("next" attribute) is DIRECTLY written, so I just change the 'next' value given in the getLoginUrl() and getLogoutUrl() function.
  2. Concerning the lost of the facebook login between the pages: the problem was that the domain of the cookie created wasn't specified, so I added " 'domain' => 'mydomain.com', " for the declaration of my new Facebook instance.


Maybe it would help some people,
Nicolas

Nicolas

related questions