apeisa Posted August 21, 2012 Posted August 21, 2012 Modules directory: http://modules.processwire.com/modules/facebook-login/ Github: https://github.com/apeisa/FacebookLogin I didn't have any real reason to build this. I actually started to just browse the documentation of OAuth implementations and discovered that Facebook really does make this easy: http://developers.facebook.com/docs/authentication/server-side/ (header "Example" on bottom of the page) so I decided to implement it. It was also nice way to test the Ryan's method of module that creates page which executes itself (like Ryan's new ServicePages module). 10
Ralf Posted August 21, 2012 Posted August 21, 2012 Hi apeisa, i´m not know if i understood that right. With this Module when i login to PW i´. automatically logged in to my facebook account and later for example i could send a posting or a new "newsentry" in my newssection to my facebook profile???
apeisa Posted August 22, 2012 Author Posted August 22, 2012 Nope. This logs you in (or creates a new user) to processwire using Facebook credentials. Similar functionality can be found from these forums for example. What permissions you give your "Facebook users" is up to you.
Ralf Posted August 22, 2012 Posted August 22, 2012 OK thanks for the further explanation - now it´s clear for me! (it was late last night )
apeisa Posted August 22, 2012 Author Posted August 22, 2012 (it was late last night ) Agreed. I thought that I build this module in 30 minutes, but it took over 2 hours of tired debugging... I haven't looked this with fresh eyes yet, so there might be something totally strange.
Nico Knoll Posted September 10, 2012 Posted September 10, 2012 How is it connect to users? I mean do I have to create a user first and then connect it to the facebook login or is it automatically creating a user?
Nico Knoll Posted September 10, 2012 Posted September 10, 2012 Doesn't you have to set a password if you're creating a user via API?
3fingers Posted November 4, 2013 Posted November 4, 2013 Hello all! Just here to ask if anybody has used this module on recent stable/dev version of Processwire and has experienced some problems. I'm in pre-production phase of designing an app and this module is needed, and wanted to be sure it stills works as expected Thanks!
apeisa Posted November 4, 2013 Author Posted November 4, 2013 i use it on few hobby sites. works great, but not the most elegant solution.
3fingers Posted November 4, 2013 Posted November 4, 2013 i use it on few hobby sites. works great, but not the most elegant solution. What do you think could be a better solution to let people register to a pw site with facebook credential? I'd like to create (just abstracting in my mind right now) a facebook app where users can upload a photo to processwire backend, using their existing facebook informations. Any suggestions other than your module, @apesia?
apeisa Posted November 5, 2013 Author Posted November 5, 2013 if you dont need local password/login then nothing bad in this solution. other options are building your own or modifying this one.
3fingers Posted November 5, 2013 Posted November 5, 2013 Thanks apesia, I'm going to look into it and trying it out right now! OT : Since some days I'm not receving any notification by the forum for new posts/replies to threads I'm following...
3fingers Posted November 7, 2013 Posted November 7, 2013 I've installed this module and played a bit to achieve what I'm trying to do. I'm going to explain my situation and relative problems I got. - What I'm trying to do : Create a facebook web app (a processwire web page nested inside a facebook tab, let's say this url "myurl/facebook-login") where the user logins (into processwire) through apesia module and (after been redirected to "myurl") can upload a picture inside his pw user page (from a form upload I've created). So far this is working, user gets created,been redirected, the form works and the image gets uploaded to his profile. Good! - What I cannot achieve: After the is redirected I'd like to post to his timeline a picture and a description. To do this I've slightly modified @apesia module to let user accepts the permission necessary to handle content upload to his timeline. Here you can find my modification (link). This works! User get prompted by facebook to accept further permissions. To post a picture to his timeline I'm playing with facebook's example (here). Here is the code I'm trying to implement (a simpyfied version just to test it): <?php require_once('../fb_sdk/facebook.php'); // THIS IS PLACED CORRECTLY $config = array( 'appId' => '', // APP ID IS PRESENT IN MY CODE 'secret' => '',// SECRET KEY IS PRESENT IN MY CODE 'fileUpload' => true, ); $facebook = new Facebook($config); $userid = $facebook->getUser(); $access_token = $facebook->getAccessToken(); $photo = 'facebook_test.jpg'; // Path to the photo on the local filesystem $message = 'Photo upload via the PHP SDK!'; if($userid) { // We have a user ID, so probably a logged in user. // If not, we'll get an exception, which we handle below. try { print_r('Success!'); } catch(FacebookApiException $e) { // If the user is logged out, you can have a // user ID even though the access token is invalid. // In this case, we'll get an exception, so we'll // just ask the user to login again here. print_r('User is logged out'); } } else { // No user, print a link for the user to login // To upload a photo to a user's wall, we need photo_upload permission // We'll use the current URL as the redirect_uri, so we don't // need to specify it here. print_r('User not found'); } ?> And here is the problem : I've always recieve a " User not found" response, but user shoud be logged by the module.... What am I doing wrong?
ryan Posted November 9, 2013 Posted November 9, 2013 I don't know enough about the Facebook API to know what's wrong here. But I would guess the Facebook authentication is failing and that you need to retrieve an error code or error message from it in order to know why. Does it have some kind of getError() method that you can call? Also your try/catch block is pointless here, as there's nothing with your try/catch block that can throw an exception. But I'm guessing that's just there as a placeholder that you'll be populating later?
3fingers Posted November 9, 2013 Posted November 9, 2013 Thanks for your answer ryan, yes...that try/catch is just there to print out those messages and let me know if login authentication succeded or not I'm still investigatin on what is happening but as far as I can tell the problem is that the token I got (after authenticating the user through apesia module) is different than the one needed to let my app perform further operations. I have to study fb php sdk better and understand how to let my users authenticate correctly without the need of this module, since (by now) is out of my skills modify it to perform as I need.
lundy Posted December 7, 2013 Posted December 7, 2013 will this work for frontend user registration where the frontend users have no access to the admin area?
Martijn Geerts Posted December 7, 2013 Posted December 7, 2013 There's no frontend vs backend. Just don't give them page-edit permissions. Give them permission you've created yourself. Create a permission `frontend_edit` and create a role `member`. On the `member` select the `frontend_edit` permission and save the member role. After this you can assign this role to a person (user). --- In your templates you can use those like this: if(!$user->hasPermission('frontend_edit')) echo 'no permission'; if(!$user->hasRole('member')) echo 'user is not a member';
3fingers Posted December 7, 2013 Posted December 7, 2013 will this work for frontend user registration where the frontend users have no access to the admin area? This modules authenticate a user giving it a "facebook-login" role. At that point you can do whatever you want, like Martin suggested.
Sanyaissues Posted February 17, 2014 Posted February 17, 2014 I was playing with the module but it doesn't creates new users. For example, If i'm logged with my processwire "admin" user and enter to myurl/facebook-login/, it adds the "facebook-login" role to the admin user (but the Facebook ID field remains empty). But if i'm not logged in and enter like a guest, it adds the role to the guest user. I was expecting that a new processwire user was created. Am i right?
dfunk006 Posted February 27, 2014 Posted February 27, 2014 Does this capture the user's email address from facebook, post authentication?
marcus Posted April 13, 2014 Posted April 13, 2014 Hi apeisa, for a hobby horse project of mine - and to learn writing modules - I took the liberty to adapt your module for GitHub registration/login: https://github.com/marcus-herrmann/ProcessWire-GitHubLoginModule GitHub is using OAuth as well, so I had to more or less modify the URLs (and for some reason, giving a stream context to file_get_contents). Disclaimer: untested so far! Proof of concept. 3
Mass Harry Posted January 21, 2015 Posted January 21, 2015 how to create post facebook api in processwire ??
guenter55 Posted August 19, 2015 Posted August 19, 2015 Hi, is it possible that this modul create pages instead of users? What I need is, that at frontend a user can sign in or register for newsletter width his facebook account and I get in site/template facebook-login childs with the username and fields with email, name, id captured from facebook.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now