PHP Classes

Facebook not returning email

Recommend this page to a friend!

      PHP OAuth Library  >  PHP OAuth Library package blog  >  How to Implement a PH...  >  All threads  >  Facebook not returning email  >  (Un) Subscribe thread alerts  
Subject:Facebook not returning email
Summary:PHP OAuth API
Messages:31
Author:victor
Date:2015-11-28 04:08:41
 
  1 - 10   11 - 20   21 - 30   31 - 31  

  21. Re: Facebook not returning email   Reply   Report abuse  
Picture of André Dias André Dias - 2016-03-09 18:45:56 - In reply to message 10 from Manuel Lemos
I have the same problem, only name and id returned. Tried with 2 different facebook accounts.

Tried both the original scope:
$client->scope = 'email,publish_actions,user_friends';

And afte reading [1] I also tried:
$client->scope = 'public_profile,email';

[1] https://developers.facebook.com/docs/facebook-login/permissions?_fb_noscript=1

  22. Re: Facebook not returning email   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2016-03-09 23:27:01 - In reply to message 21 from André Dias
It seems some accounts do not have a email associated because the user logged in with his mobile phone number. Is that the case of the accounts you are trying?

  23. Re: Facebook not returning email   Reply   Report abuse  
Picture of André Dias André Dias - 2016-03-10 08:34:52 - In reply to message 22 from Manuel Lemos
Not really, I was thinking if it had something to do with the configuration of the app in facebook but there isn't any option to allow/disallow scopes from there. All I wanted was to get the return like in your image attachment.

I will try the facebook SDK to compare the results.

Another thing I noticed is that I enabled the debug but nothing is printed on screen:

$client->debug = true;
$client->debug_http = true;

Does it go somewhere else?

  24. Re: Facebook not returning email   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2016-03-10 08:48:32 - In reply to message 23 from André Dias
What may have happened is that you started with one scope without email and obtained a token. Then if you changed the scope variable to add email, it will not change the scope of the token you already retrieved.

If you did that, you need to start over, for instance calling ResetAccessToken, so it forces the class to obtain a new token with the correct scope.

  25. Re: Facebook not returning email   Reply   Report abuse  
Picture of André Dias André Dias - 2016-03-10 09:01:57 - In reply to message 24 from Manuel Lemos
Yes, I read the whole thread so I'm aware that this could happen. I tried 3 browsers mixed with 2 different accounts in 2 different computers, it is not a random error =)

  26. Re: Facebook not returning email   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2016-03-10 09:22:31 - In reply to message 25 from André Dias
That is odd. Did you try Facebook SDK and checked if it had the same problem? If yes, so there is no issue with the class. It may be something specific to your application or those user accounts.

If you did not have the same problem with Facebook SDK, just let me know so I can figure if it is something related with this class.

  27. Re: Facebook not returning email   Reply   Report abuse  
Picture of Nick Lüthi Nick Lüthi - 2016-08-05 14:27:57 - In reply to message 26 from Manuel Lemos
I ended up with appending fields after me

$success = $client->CallAPI('https://graph.facebook.com/v2.7/me?fields=email,first_name,last_name',
'GET', array(), array('FailOnAccessError'=>true), $user);

oauth 2016-07-22 and facebook api version 2.7
is this wrong?

thanks

  28. Re: Facebook not returning email   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2016-08-05 15:16:05 - In reply to message 27 from Nick Lüthi
Oh, you are using a newer API version. That probably requires the fields to be listed explicitly.

  29. Re: Facebook not returning email   Reply   Report abuse  
Picture of André Dias André Dias - 2016-08-06 00:05:04 - In reply to message 27 from Nick Lüthi
For me it also never worked out of the box so I also needed the extra call (which I used to request some other free stuff as I needed it for the email anyway):

$success = $client->CallAPI(
'https://graph.facebook.com/v2.3/me',
'GET',
array('fields'=>'first_name,last_name,gender,email,timezone,age_range,verified'),
array('FailOnAccessError'=>true), $user);

  30. Re: Facebook not returning email   Reply   Report abuse  
Picture of Nick Lüthi Nick Lüthi - 2016-08-06 06:22:50 - In reply to message 28 from Manuel Lemos
Api versions greater than 2.3 or 2.4 (=?) will not return an email even if you specify $client->scope = 'email';
No problems found for example with apps using facebook api version 2.0

 
  1 - 10   11 - 20   21 - 30   31 - 31