I am about to start a new project building a web UI with a lot of different functionality. Part of the functions however include the ability to update and access certain social media sites – Facebook and Twitter primarily.
I would like the user to login to the system and then also have the ability to manage multiple FB/Twitter accounts so that they can interact with these all from one place without having to authenticate every time they go to do something. For security reasons I obviously don’t want to store passwords, but I’m not sure how to go about this one.
I know it’s possible – does anyone have any pointers on how to go about this?
FYI – I’m programming in PHP, Javascript/Jquery. Thanks in advance!
Here is the Facebook part. A good and easy way to do that is to use the Facebook PHP SDK (see on github). So you will have something like :
If the user is logged in, then
$useris his Facebook ID. You then have to check if you have a valid access token by making an API call :If it does not raise any exception, then you have a valid access token
If it does, then you have to re-authenticate the user.
Here you go :
You need then to display the login or logout link :
When the user is logged in and you have a valid access token, you can make API calls to get data from Facebook :
You may want to check the example page of the Facebook PHP SDK which is well documented.
Hope that helps.