Facebook connect for phpBB
Posted by Stephan onAs I mentioned in a previous post, I’m trying to get a phpBB forum to allow user registrations using Facebook Connect. So far all looks good, so I’ll explain how I managed to do this.
Disclaimer: I do not support this plugin.
Also, I did not develop this plugin and cannot guarantuee that it’s safe.
Having said that, if you’re as stubborn (or desperate for a Facebook plugin for phpBB) as I am, keep on reading. (Note: I’ll just assume you have already installed the latest version of phpBB. If not, you may want to go here first: Download phpBB.)
Getting a Facebook API key
To be able to even connect to Facebook you will need to create an application. Unfortunately, this means you’ll have to verify your Facebook account by filling in a cellphone number or credit-card. This sucks, but it’s necessary. Once you’ve created an app and filled in all the right information, you’ll have some info that you can use to verify yourself as the creator of the app. For the plugin we’re installing you will need you Application ID and your Application Secret Key.
Download the plugin
Once upon a time some guy called Skinny Vinny developed a plugin to add Facebook Connect to phpBB. Unfortunately, he disappeared off of the face of the internet, taking his website svmods.com along with him. Developing of the mod was discontinued, the original file was nowhere to be found anymore and nobody else came up with the idea to pick it up again. I would have loved to start the development of a new plugin, but unfortunately I’m not familiar enough with PHP to start something like that from scratch. Instead, I managed to find the zip-file with the plugin by Skinny Vinny somewhere in an archived page, which I’m going to use.
Note: as the plugin page states this plugin was not completed, not has it been tested for security flaws. Use it at your own risk.
Download the Facebook Connect for phpBB plugin here: svmods_facebook_connect_for_phpbb.zip
Installation
One thing I hate about phpBB is the way you have to actually edit the core files if you want to use a plugin. Decent software like vBulletin or MediaWiki has plenty of hooks which you can use to launch a plugin with, without having to modify the system files. To make this a little easier, a plugin was developed for phpBB called Automod, which installs a plugin automatically for you, saving you the trouble of having to edit the files manually. For some reason however, the Facebook plugin does not work with Automod. This means we have to install it manually after all. Fortunately though, the amount of edits is relatively low (compared to some other plugins) so it shouldn’t be too much of a pain.
Make backups
First of all, backup your forum files and database. If you don’t know how to backup your database, see this tutorial: Backing up your phpBB database.
Backing up your files is as easy as connecting to your server with an FTP-client and downloading the entire /forums/ (or whatever you have called it) folder to your PC.
Upload files
After you’ve backed up your forums, you can start uploading the plugin. In the plugin’s zip-file you just downloaded there’s a folder called /root/. Open it, and upload the contents into the folder on your server that has the forums in it.
Probably you will get a prompt asking you if you want to overwrite the /includes/ and /languages/ folders. This means you’re uploading into the right directory. Just click ‘yes’.
Adding the plugin code to phpBB
This is where the fun part starts: you will have to make some changes to the phpBB core files. In the downloaded zip there’s an install_mod.xml file. Open it, and follow the instructions. It’s not that hard, and if you mess it up just restore your foums by uploading your backed-up files to the server again and try over.
Activating the plugin
Finally, to activate the plugin you’ll have to log in to the Administration Control Panel of your forums. Purge the cache, and then go to the Board Settings page. Here you’ll find a section where you can add your Facebook Application ID and secret (the ones you saved from before when you made a Facebook Application). Hit the submit button, and you should be done!
Questions, etc.
As always, if you have any questions, remarks or feedback just let me know in the comments below or tweet me at @Litso_. I’m seriously interested in getting this plugin to an official status, so if you’re a PHP developer and you want to help me out making this plugin better, let me know! I think there’s a lot of people wanting to use this plugin, so let’s give them something good!

Hi,
Thanks, its worked for me. But logout not happening.
Hey,
I seem to have the same problem.. I tried to fix it but I can’t find out where it’s going wrong..
I’ll let you know when I find out
Stephan
Thanks Stephan
Hi Stephan,
any luck for logout issue?. Its urgent for us. sorry.
it dosent work on phpbb3 3.0.8 ??
when i run test.php it said
Information
Your server failed to retrieve data from facebook.
It appears incompatible with this hook/mod. If you have already uploaded the hook_svmods_facebook_connect.php file, please delete it and purge your cache from the ACP.
where can i add my data? in board settings there
The test.php error isn’t a version thing. It means you are missing a component. I’m on 3.0.8 and dont get that.
I don’t get the values in board settings. Did I miss a step? I don’t see where the ACP was updated.
Hi,
Thanks a lot for reply. Let me check and will update here.
Hi cRobG,
Go to board settings in “Board Configuration”. The we can find Svmods Facebook Settings as following list, Facebook application ID, Facebook application secret and Use remote redirect for Facebook avatars?.
Hi,
just I got resolved like below in hook_svmods_facebook_connect.php
else if (request_var(‘mode’,”)===’logout’){
$cookies=array_keys($_COOKIE);
$domain=’.’.$config['cookie_domain'];
foreach($cookies as $cookie){
$when=time()-3600;
setcookie($cookie, “”, $when, “/”, $domain);
}
//if (isset($_COOKIE['fbs_'.$config['svmods_facebook_app_id']])){
// setcookie(‘fbs_’.$config['svmods_facebook_app_id'],NULL,time(),’/');
// unset($_COOKIE['fbs_'.$config['svmods_facebook_app_id']]);
//}
}
Ok so where in the file does this go?
i.e. Find….
Add After or add before what?
Did this resolve the issue?
else if (request_var(‘mode’,”)===’logout’){
$cookies=array_keys($_COOKIE);
$domain=’.’.$config['cookie_domain'];
foreach($cookies as $cookie){
$when=time()-3600;
setcookie($cookie, “”, $when, “/”, $domain);
}
//if (isset($_COOKIE['fbs_'.$config['svmods_facebook_app_id']])){
// setcookie(‘fbs_’.$config['svmods_facebook_app_id'],NULL,time(),’/’);
// unset($_COOKIE['fbs_'.$config['svmods_facebook_app_id']]);
//}
}
Stephan, I must say you saved my day. Had to spent few hours before I landed onto this page.
Plugin woks flawlessly, except to log out case, but I’ve managed to fix it.
If anyone cant find a way out with log out – email me.
Good luck!
hello
first thanks to Stephan for sharing this extention
second Justafa would u tell us how u fixed the logout issue btw i like ur page
thanks
or if like
mail me a tip @ i can’t see ur email any where
thanks again
the logout code is not working .. i changed as suggested in the above few posts !!! please help .. Can anyone suggest how to get users log out ?
look for facebook kill session code didn’t test it yet but i think it should work
reply if it worked for u plz
Also Is this modification right in overall_header.html ??? there is no field for svmods_facebook_xmlns ?
Figured out the logout part …
//$domain=’.’.$config['cookie_domain'];
$domain=”.”;
This is the code from the question above
html xmlns=”http://www.w3.org/1999/xhtml” {SVMODS_FACEBOOK_XMLNS} dir=”{S_CONTENT_DIRECTION}” lang=”{S_USER_LANG}” xml:lang=”{S_USER_LANG}”
$doman=”.yourdomain.com”;
Hello Aditya,
Are you resolved?. or you are getting what error?.
just I got resolved like below in hook_svmods_facebook_connect.php
else if (request_var(‘mode’,”)===’logout’){
$cookies=array_keys($_COOKIE);
$domain=’.’.$config['cookie_domain'];
foreach($cookies as $cookie){
$when=time()-3600;
setcookie($cookie, “”, $when, “/”, $domain);
}
//if (isset($_COOKIE['fbs_'.$config['svmods_facebook_app_id']])){
// setcookie(‘fbs_’.$config['svmods_facebook_app_id'],NULL,time(),’/’);
// unset($_COOKIE['fbs_'.$config['svmods_facebook_app_id']]);
//}
}
sir… i have installed this mod into my phpbb3…
but sir..after i followed all the instructions…yeah.. it worked…
but my template doesn’t work anymore…
this is my website
http://wisdomskyi.tk/forum
please help
@Wisdomsky
It seems that the head area of your template is missing.
If you have a backup you can restore it by search for the head-Tag an copy everything to your template again. It should be in overall_header.html
Good luck and sorry for my bad english
@Stephan thanks for sharing this plugin! Maybe i can help to get this to an “official” state
Greetings
LittleFox
By all means LittleFox, go agead and do what you want with the plugin
. As you can see I neither have the time nor the knowledge to further improve this plugin, and the source code is totally free from copyrights or anything. Do as you wish, as long as it serves the community!
OK, when i find some time i’ll improve this plugin.
) so i also don’t have a lot of free time. But sometime i need a break, then i do things like this 
But currently i’m working on another project (an operating system
I’ll post a comment if something got changed.
Greetings
LittleFox
Hi Guys,
I have followed all the instructions and i am now permanantly logged into my site and cant logout. I have replaced the code in hook_svmods… as detailed in above posts but still i am logged in, any help would be appreciated.
Dave
Hi, Thiyagarajan Veluchamy
I made the changes but I am still logged in, I cleared all the cache but no joy.
Any ideas?
Hi, i’ve made all the changes and uploaded files, but i can’t see the options under “Board Settings”, can you help me please?
Thanks, Marco
Hi, how to make apps in http://www.facebook.com/developers/createapp.php?
I decided to try this. But I read through the old posts for it on the PHPBB website and saw that the author had added Automod support. So just for grins I decided to give that a try. It had one error during install but I forced it anyway. It seems to have worked but with one problem. I don’t have the Facebook Connect icon on my header, it only shows up if you click the login link.
Any suggestions?
Follow up….
Using Automod actually did not work. Neither did making the changes by hand. When you try to login using FB it sends a bunch of errors and gives a warning about using an incorrect browser. Strangely enough it seems to work if the user is using Chrome. Go figure. Anyway, this would have been a nice feature, but I don’t really care if I have it or not. I’ll keep checking this board and see if any solutions come up.
I solved it, i scrapped phpbb and got SMF, the facebook connect module works flawlessly!
I spent too much of my life trying to get this module working, it simply doesnt.
Dave
Hello I edited the like below
else if (request_var(‘mode’,”)===’logout’){
$cookies=array_keys($_COOKIE);
$domain=’.’.$config['cookie_domain'];
foreach($cookies as $cookie){
$when=time()-3600;
setcookie($cookie, “”, $when, “/”, $domain);
}
//if (isset($_COOKIE['fbs_'.$config['svmods_facebook_app_id']])){
// setcookie(‘fbs_’.$config['svmods_facebook_app_id'],NULL,time(),’/’);
// unset($_COOKIE['fbs_'.$config['svmods_facebook_app_id']]);
//}
}
But after purge the cache the site was not loaded.then again I will set old file to same location.After that site will works again.please help me to solve this issue.
nice post… thanks
Is it still working with phpbb 3.0.9?
Yes, it works with phpBB 3.0.9
Logout Problem !!!
Mod works fine, but there really is a logout problem. Has anyone really resolved it?
The FB avatar doesn’t work – for some reason this mod writes the address of FB avatar http://fbuserpic.svmods.com/pic_number.jpg. I believe that the path to FB avatar should be related to some FB URL, not svmods.com.
Any idea from where should I start to fix this?
I used the pluggin
everything went smooth BUT
when I first logged in it gave me an error:
An error occurred with moha. Please try again later.
API Error Code: 191
API Error Description: The specified URL is not owned by the application
Error Message: redirect_uri is not owned by the application.
and I can not log in again because it gives me the same message if I try to log in
any ideas?
when I try to log it it gives me this warning in a box
(above the boxes where I would fill my mail and pw)
Invalid Argument
Given URL is not allowed by the Application configuration.
Hello,
I have been using this plugin for over a year and it has been working great, now all of the sudden Facebook changes their Oath2 authentication and it no longer works…Does anyone have a fix?
http://blog.logiclabz.com/javascript/facebook-login-error-oauth2-specification-states-that-perms-should-now-be-called-scope.aspx
Looking for a solution here too looks like I may have to start modifying the php code in the hook file mysql.
mysql = myself
I am not mysql!
I have been trying to fix this for hour and hours. Something just isn’t working right anymore. If you change the perms to scope like is required… it still doesn’ log the user in. It just refreshes the page. If anyone has a fix please let me know!
Hey folks,
Sorry for never having replied to the comments here. I’m far too busy nowadays to keep this blog running, but I don’t want to shut it down because there’s some posts like these that still get a lot of people commenting and helping eachother out.
I’ll fix the download link, but I don’t use phpBB anymore myself so I won’t be fixing the plugin.. sorry! If anyone else does please do send me the updated code so that everyone that googles and finds this post can get it too.. of course I’ll totally credit you.
I posted this a few days ago.. but it wasn’t approved…
I got it to work.
You need to update the Perms to Scope, update the facebook cookie code from fbs to fbsr and also update the svmods_get_facebook_cookie with the one found here: http://blog.codebusters.pl/en/entry/oauth-20-facebook-changes-and-cookie-problem-in-codeigniter/
You just need to add in a few svmods specific things like this:
$user->data['svmods_facebook_data']['cookie'] = $data;
$user->data['is_facebook_user'] = $data['user_id'];
$user->data['is_facebook_connected'] = 1;
And the app id and secrets. I am still testing, and am still need to figure out an authentication issue.. but everything works again.
Oops, apologies! That comment might have ended up in the spam folder. I’ll try and update my code and test if (if I still have an old copy of the phpBB forums lying around)!
So AJ Quick,
I’m not a programmer. Could you explain just a little more detailed? I get the “Perms” to “Scope” but where do you want me to put the three lines of code?
Best regards,
Espen Klem
AJ Quick,
Any chance you can put up a link to your version of the hook_svmods_facebook_connect.php ? Also did you change the JSON.php file as well?
Cheers,
James
guys, I made the changes like explained (AJ Quick).. but nothing to do, it does not work for me… here is my file if somebody wants to work it more
http://dl.dropbox.com/u/2930979/myfile.txt
You don’t have the access token being passed. That might be the problem.
Add:
$data['session_key'] = $data['code'];
After:
$data['access_token'] = $params['access_token'];
Thanks for the suggestion, I missed it.. but unfortunately it is no the problem.. when I install the hook, loading the home page results in an empty page. I have no output, I can’t debug like this without seeing what is going on…
Try clearing your cache on the forum. I had that problem too when updating my script. If you can’t login, try removing your hooks file and emptying the “cache” folder.
yeahh, cleaning the cache was one of the first thing I did.. the problem is that there is something wrong in my hook file. when I set it in use phpbb crashes at all and I get white pages everywhere, home, admin.. everything stops working, as expected the hook file is loaded from anywhere and fails … no errors displayed, no echo or print are working to troubleshoot a bit more and check the content of the variables and the cookie..(can’t print the cookie out..) simply a white page. it’s impossible to troubleshoot blinded …
so the only way to get the forum working again is rename the .php hook file so it is not loaded anymore..
it looks something linked to the template too, so I disabled the customer style and used the original one .. but nothing helps…
this is the last ver of my file http://dl.dropbox.com/u/2930979/myfile.txt
if somebody can make it working, let me know… Can I see your working version? thanks for your help…
I used to have this hook installed on my forums, but was forced to remove it once facebook changed their API in December. I would love to get it working again – are you using 3.10 or 3.09?
I am on 3.10… but as you read.. not working for me
It not work … :/
Hey I got this from you yesterday, was very excited but i can’t seem to get it to fully work.
I backed up everything and I have cleared the cache multiple times, tried 2 different versions of firefox and one version of IE and the response i get is this:
An error appears to have occurred with your browser. If you wish to use the sites Facebook logins or registration features, please update/repair your browser, or use a different browser.
We applogize for the inconvenience.
is there anything that I can do?
Should I just remove the app?
Currently using phpbb 3.09 but planning on updating in the next couple of days.
I have abandoned using this mod because it is no longer supported – I implemented this one last week and it seems to working pretty well: http://www.phpbb.com/community/viewtopic.php?f=70&t=1883675
I made the changes as “Thiyagarajan Veluchamy” wrote, and also the “AJ Quick”. It’s working perfectly, including the logout. The only thing that isn’t works is to get the avatar image in facebook to use phpbb. (As the “Jude” wrote). I will try to resolve it … If someone can, please post here! Thank you.
I managed to get the avatar facebook! Now the module works perfect! Better that than the “Neil” indicated, because it is simpler and connects on facebook without opening another page.
To run the avatar:
- Comment the following line:
fb_avatar_url $ = “http://fbuserpic.svmods.com/ ‘;
- And add the following line below:
$ = $ fb_avatar_url server_url. ‘/ facebookuserimage’;
Check qiaolun’s svmods-fork. I’ll give it a try soon.
Homepage for svmods code library on GitHub.
It did not work. Got a blank page instead of the phpbb.
Maybe because I am using SEO.
Hi, please check out an updated plugin for Facebook OAuth which is basically Facebook connect. I now call it OAuthorize phpBB so that I can add more providers in the future.
Find download information(Github) from the mod page
I’m not new with such plugins as I had this I think a year ago but lost my hosting. Everything is in GitHub now.
I hope you try and contribute.