Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting FB accounts with accounts on my website

please help me or just give me a hint where should I start, because I've been fighting with this for 2 weeks.

As we all know, facebook has a new auth system which means I have to implement it on my website and I just can't understand how it works and how to implement it on my website. Of course I know there are examples over the Internet and on Developers page - I had read them all and still don't know how to acheive linking accounts on my website with FB accounts. Maybe I will present some situations I need to cover:

The website has local accounts. There is an additional DB table which can link my user ids with FB user ids.

  • Situation 1: a new person comes to my website. He/She does not have my website's account but does have FB account. He/She clicks on "Login with facebook", gets redirected to FB, authorizes the app and gets redirected back to my website which creates a new user account and connects my website's uid with authed FB uid.

  • Situation 2: a person has an account on my website, already connected to some FB account. He/She clicks on "Login with facebook", my website finds FB uid in "link" table and logs in the user which is connected to that FB account.

  • Situation 3: a person has an account on my website which is not connected to any FB account. He/She goes to a special panel on my website with a link "Connect this account with Facebook". He/She clicks on it, authorizes the app, gets redirected back to my website which creates a record in "link" table connecting website's uid with facebook uid. After making the connection that special panel shows an info "Your are connected to <John Doe> facebook account. [Unlink]".

  • Situation 4: a person is logged in to my website to an account which is connected to Facebook account. He/She does some actions on my website which result in posting messages on his/her FB wall.

So TL;DR, a normal functionality of making a bound between FB accounts and accounts on my website.

With previous API everything was fine and working, there was also offline_access I could use for posting on wall, there was no tokens for that etc., you know.

Right now.. I don't know where to start, where and how I should store these tokens, how to get them and on what occasions, how to link exiting accounts, how to "update" existing "bounds" in my "link" table.

Just simple hints in pseudocode or a list of 1..2..3.. steps how this flow should look like would be really helpful guys because I can't find any helping information on the Internet. Every "example" or "tutorial" for this new API tells how to just authenticate FB account on your website but not how to really connect these accounts to something or store this connection for example in the database.

I use latest PHP Facebook SDK.

like image 942
Cliff Edge Avatar asked Nov 05 '22 01:11

Cliff Edge


1 Answers

Check following for oAuth authentication guide

https://developers.facebook.com/docs/authentication/server-side/

after implementing that you can got access_token,

now you can save user in your db using that access_token.

like image 136
Rajesh Meniya Avatar answered Nov 15 '22 05:11

Rajesh Meniya