Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Hi guys,

I've been trying to implement the facebook login for the members module discussed here:
viewtopic.php?f=5&t=8063&hilit=facebook+login&start=10

But I keep getting this error message when trying to login:

We require permission to view your Facebook email address to register and log in

The facebook app is active and the following login permissions are approved: email, public profile and user friends.

please help
I think the cause of this problem might be that my privacy settings block the emailadress. The same problem exists when I use the javascript code provided by facebook.

I think I found a workaround for people with blocked email adresses.

Code: Select all
// get email
                try{
                    $user_profile = $facebook->api( '/me','GET' );
                    if( !isset($user_profile['email']) || empty($user_profile['email']) ){
                        $user_profile['email'] = 'facebook@mydomain.com';
                    }
                   
                }catch( FacebookApiException $e ){
                    return KFuncs::raise_error( $this->t['error'] );
                }


I don't know much PHP though. I hope I did the following here:

-Check if the email value is empty
-if the email value is empty set the value to facebook@mydomain.com
Could we also change the static facebook@mydomain.com to the default facebook emailadress: user.name@facebook.com ?

Code: Select all
// get email
                try{
                    $user_profile = $facebook->api( '/me','GET' );
                    if( !isset($user_profile['email']) || empty($user_profile['email']) ){
                  $str = $user_profile['name'];
                  $str = strtolower ($str);
                  $str = str_replace(' ', '.', $str );
                  $mail = $str + '@facebook.com';
                  $user_profile['email'] = $mail;
                       
                    }
                   
                }catch( FacebookApiException $e ){
                    return KFuncs::raise_error( $this->t['error'] );
                }
               


I've tried this but it ends in a member_email: Invalid E-mail

PHP really isn't my thing...
Ok So I've managed to get it to work, here's the code:

Code: Select all
 // get email
                try{
                    $user_profile = $facebook->api( '/me','GET' );
                    if( !isset($user_profile['email']) || empty($user_profile['email']) ){
                       
                  $mail = str_replace(' ', '.', $user_profile['name']);
                  $mail2 = strtolower ($mail);
                  $fbmail = '@facebook.com';
                  $mail3 = $mail2.$fbmail;
                  $user_profile['email'] = $mail3;
                  
                    }
                   
                }catch( FacebookApiException $e ){
                    return KFuncs::raise_error( $this->t['error'] );
                }
               
4 posts Page 1 of 1