About fbLogin

fbLogin is a MODX extra which extends Shaun McCormick"s Login extra to enable users to register and login to a site using their Facebook account via the Facebook API using Version 3.0 of their PHP SDK.

Information

Released
February 20, 2012

Supported Database
MySQL, SQL Server

License
GPLv2

Supported Versions
2.1 - <2.2

Downloads
3,310

Instructions

1. Plan your Facebook integration, at least have a good idea 

of what you can do with the API and the permissions you may 

need to obtain from your users to make what you want to 

use the API for happen. It will make life a lot easier 

for you if you do this in advance.

2. If you have not already done so, install the Login extra 

from Package Manager.  This MUST be installed for this extra 

to function.  You should set up your registration and login 

system and have them working completely before you make a 

start setting up this extra.  In addition, you should have 

a dedicated login page, a dedicated registration page and 

a protected account page where registered & logged in users can 

manage their profile and other account details. Once that 

is all done and working, proceed to step 2.

3. If you haven't already done so you will need to go to the 

Developer App on Facebook and create a new app for your site - 

https://developers.facebook.com/apps.

4. Take note of the App ID and App Secret Facebook have assigned 

to your newly created app.

5. Also, while you are there, click on the advanced tab and enter 

a URL on your site to a resource that Facebook can ping to inform 

you of users who have de-authorised your app. Make a note of the 

URL you have chosen for this purpose.

6. Install this extra from package manager.

7. Add the system settings as described under the System Settings

section of this readme

8. Create a resource which will be available at the URL you entered 

above for Facebook to ping with de-authorisation notices. This 

resource should be publically available, published and should have 

its template set to none and have caching disabled. In the content 

field for this resource, call the fbDe-authorised snippet uncached 

- i.e. [[!fbDe-authorised]].  Save that resource.

9. Create another resource which is also publically available, has 

its template set to none, its caching disabled and is also published 

and place an uncached call to the fbRedirect snippet on it - i.e. 

[[!fbRedirect? &cancelUrlId=`x` &returnUrlId=`y`]] where x is the 

id of your dedicated login resource and y is the ID of the resource

 we are about to create next. Save that resource.

10. Create another resource which again is publically available, has 

its template set to none, its caching disabled and is also published 

and place an uncached call to the fbLogin snippet on it as follows:

[[!fbLogin? &usergroups=`A` &postLoginUrlId=`B` 

&fbRedirectUrlId=`{{*id]]` &perms=`C`]] where A a comma delimited list of 

the user groups (if any) you would like your new Facebook user to 

belong to, B is the ID of the resource returning Facebook users 

should be redirected to after a successful login and C, a comma delimited

 list of the permissions you want your user to grant.  This list should 

be the same across all calls to this snippet.

11. On all protected pages you must have a call to the checkForActive 

snippet - there are no paramaters required so the call just looks like

[[!checkForActive]] - if you have a particular template for your 

protected pages it could be added to that.

12. If you already have a set of links on each page of your site for 

logging in and registering for users who are not logged in and links to 

allow users to log out and navigate to their main protected account page,

replace those with the fbLink chunk (uncached) which you can then 

style with CSS and parameters - see below.  A sample call to it might 

look as follows:

[[!$fbLinks? &fbLinksSeparator=`|` &fbLinksAltSeparator=`/`

&fbLoginLinkText=`Sign In` &fbLoginLinkTitle=`Log in to your account` 

&fbLogoutLinkText=`Sign Out` 

&fbLogoutLinkTitle=`Log out from your account` 

&fbRegisterLinkText=`Sign Up` &fbRegisterLinkTitle=`Register with us` 

&fbAccountLinkText=`Your Account` &fbAccountLinkTitle=`Manage your 

account info` &fbLoginLinkId=`A` &fbRegisterLinkId=`B` 

&fbAccountLinkId=`C` &fbLogoutLinkId=`D` 

&usergroups=`E` &postLoginUrlId=`F` &newUserUrlId=`G` 

&fbRedirectUrlId=`H` &perms=`I`  

&fbLoginTitle=`Save time and get some extra integration with 

Facebook by using Facebook to register and log in` 

&displayProfileImg=`1` &postLogoutUrlId=`J`]]

where:

A is the ID of the dedicated resource you use for logins

B is the ID of the dedicated resource you use for registration

C is the ID of the dedicated protected resource you redirect 

users to on successful login

D is again the ID of the dedicated resource you use for logins

E is a comma delimited list of usergroups (if any) that you 

want neely added Facebook users added to.

F is again the ID of the dedicated protected resource you 

redirect to after a successful login

G is the ID of a resource you want new Facebook users to be 

redirected to after they register - say to complete their profile

H is the ID of the resource you set up in step 9 above.

I is the comma delimited list of permissions you want to 

request from the user on Facebook

J is the resource you would like to redirect to when Facebook 

users log out.

13. You can customise the way this extra works further by editing the

chunks provided in the fbLogin category.

New in 1.0.0-rc1

Initial content

Current releases