Skip to content
This repository has been archived by the owner on Mar 29, 2019. It is now read-only.

Graph Api 2.4 ('/me') returns name and id only #41

Open
flexroad opened this issue Jul 21, 2015 · 17 comments
Open

Graph Api 2.4 ('/me') returns name and id only #41

flexroad opened this issue Jul 21, 2015 · 17 comments

Comments

@flexroad
Copy link

I have setup new Facebook app and it is under the api version 2.4. When I call php $fb->api('/me'); it returns name and id only... What I need is email as well. Any ideas?

All works perfectly with 2.0 and 2.2 (other fb apps I'm using)

@fprochazka
Copy link
Member

@flexroad you probably have to ask for the permissions in the app settings in developer console in facebook.

@fprochazka
Copy link
Member

If it's a bug of this extension, please reopen.

@flexroad
Copy link
Author

As I said... When I use different facebook app (v 2.2) (I have changed appId and 51a76f436572195b41550af7a21fb84d) all works perfectly.

I looks like some incompatibility between current kdyby/facebook and facebook graph api v2.4.

@fprochazka
Copy link
Member

Kdyby is not changing any responses, it just returns what it gets from the api

@fprochazka fprochazka reopened this Jul 21, 2015
@fprochazka
Copy link
Member

I have very little time to investigate this right now. Can you debug it please?

@flexroad
Copy link
Author

I have no idea how to do that. :( Any article about "debug it please"? Cheers.

@davidkrmela
Copy link

I think that Kdyby\Facebook\Facebook::api behaves correctly. If you want email in v2.4, you should call:

$fb->api('/me', NULL, ['fields' => 'email']);

But there is problem with Kdyby\Facebook\Profile::getDetails that does not return required field. Temporary fix could be, for example:

public function getDetails($key = NULL)
{
    if ($this->details === NULL) {
        try {
            $this->details = $this->facebook->api('/' . $this->profileId);

        } catch (FacebookApiException $e) {
            $this->details = array();
        }
    }

    if ($key !== NULL) {
        if (!array_key_exists($key, $this->details)) {
            try {
                $fields = $this->facebook->api('/' . $this->profileId, NULL, ['fields' => $key]);
                $this->details[$key] = isset($fields[$key]) ? $fields[$key] : NULL;

            } catch (FacebookApiException $e) {
                $this->details[$key] = NULL;
            }
        }
        return isset($this->details[$key]) ? $this->details[$key] : NULL;
    }

    return $this->details;
}

@davidkrmela
Copy link

see Declarative Fields @ https://developers.facebook.com/docs/apps/changelog#v2_4

@JakubTN
Copy link

JakubTN commented Aug 6, 2015

@davidkrmela your example didn't work for me. For me, only little modification in request call helped:

$me = $fb->api('/me?fields=id,first_name,last_name,picture,email');

I have to specify requested fields right after /me string and everything works fine. Statement with fields specified as 3rd param of ->api method didn't work for me.

@davidkrmela
Copy link

@JakubTN that's strange. On master, I just tried:

$me = $fb->api('/me', NULL, ['fields' => [
    'id',
    'first_name',
    'last_name',
    'picture',
    'email',
]]);

and gives me same result.

@JakubTN
Copy link

JakubTN commented Aug 7, 2015

@davidkrmela I'm using 2.0.0., maybe that's the reason.

@ilian6806
Copy link

Since v2.4 , the graph API requires that you explicitly request the field(s) you need for your GET requests.
You can see the change log.

@iad24
Copy link

iad24 commented Mar 8, 2017

Now Im not getting the email
I have developed my facebook login function like 1 year ago and it was working before.
Im already using API 2.4, pod is 4.9.1.
Then suddenly all platforms not working (android, ios, web)

For iOS, i have it this way:

let req = FBSDKGraphRequest(graphPath: "me", parameters: ["fields":"id,email,name"], tokenString: tokenString, version: nil, HTTPMethod: "GET")
        req.startWithCompletionHandler({ (connection, result, error : NSError!) -> Void in
            SGLogger.logDebug("result=\(result), error=\(error)")

I am already putting 'email' in the fields.
Anyone having this issue lately???

@jaiswarvipin
Copy link

One of the my friend was trying to the issue from last 5 days. huummm very irritating. which got love in 2 min...

Assumption: using PHP for O2Authentication
Solution:

$loginURL = $fb->getLoginUrl({your redirect URL},['email']);

And job is done.

Thanks & Regards
Jaiswar Vipin Kumar R.

@sergeylukin
Copy link

sergeylukin commented Feb 7, 2018

Came here because had same problem with Javascript SDK, unrelated to Nette project, and your inputs guys helped me, indeed had to pass ?fields explicitely in /me request in order to get email and other values, more details in Facebook SDK v.2.4 changelog

@developer11
Copy link

One of the my friend was trying to the issue from last 5 days. huummm very irritating. which got love in 2 min...

Assumption: using PHP for O2Authentication
Solution:

$loginURL = $fb->getLoginUrl({your redirect URL},['email']);

And job is done.

Thanks & Regards
Jaiswar Vipin Kumar R.

thanks man

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants