Website Log In with Facebook - PHP

Hi
I am working on my website on PHP, and at some point, it is required to have a membership. I added the "Login with Facebook" but it is not working with me fully. When the user clicks on Login with facebook, it takes him/her to facebook and it returns him/her back to my website with a very big code that I do not know what to do with it.


The return URL is :
https://mysite.com/login.php?code=AQDcQ5bNp5cIfBP-RP1R5H1LhZq2a6gx3Hva2c_jHEvLt942jvVgDS-ECqQ4z0amu9FN1uBkWV1ru_PbTkg4T7YXfLls2dSkI-Z878jZFPu8PowOn4q4Ijs6ZGmijAEXb95D1AcYIxGNw3tuZV_ap0ub2rT4Rb73RkxSvkr6W2bfuGzyc4HxvJEdhqoXEk0hTBD2CDgzCYD8tldEEyFVNPxNE4YdtbsqsTwIpEk40cTv-gCVgZnMYCKMYzMRypk9ZeO13wA8sIlb2oD6HDly50_W77vj5O0Ojn-FspBjIp7lTMrNbUvfv2V-A9W5TdAUp1W1FoAkLTuzgST7jnypacVS&state=36a55933bbbe05b922d295b754ecf1c0#_=_


My login page is as per below:

Login.php

I already uploaded the files from GetHub "php-graph-sdk-5.x.zip"
Facebook files

- What should i write inside the login.php to get the user details ? I need the email at least.
- How to understand the return URL?
LVL 1
zoscoitNetwork AdministratorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Olaf DoschkeSoftware DeveloperCommented:
Read this thoroughly: https://developers.facebook.com/docs/php/FacebookRedirectLoginHelper/5.0.0
The URL code parameter says nothing to you, it's for FB to know your request is genuine and also encodes what permissions you'll want, it doesn't yet give you the email, the login didn't yet occur, you're pre-login here.

The result of the request is what you're interested in, and you should not let the login.php callback to itself, or you don't have a good distinction between before and after login.

As in the example, let getLoginUrl create a URL, which calls a login-callback.php page of your website and then do something along the lines of the login-callback.php sample code.

Bye, Olaf.
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Olaf DoschkeSoftware DeveloperCommented:
The answers explains how this works pretty straight forward.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.

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.