Search code examples
phpfacebooksymfonyhwioauthbundle

Symfony2 - HWIOAuthBundle How to get the information that I set on paths


I am implementing this Bundle in my project, but it provides the information fields Nickname, Username, realname, Email ...

I also need the Firstname, Lastname and Birthday field

How do I add or override these methods?

My Settings: config.yml


hwi_oauth:
    firewall_name: secure_area
    connect:
        confirmation: false

resource_owners:
    facebook:
        type:                facebook
        client_id:           454595989899812
        client_secret:       eba0d566631eec3e012545a5f28443dd4
        infos_url: "https://graph.facebook.com/me?fields=id,email,first_name,last_name,gender,birthday,locale,location,picture.type(square)"
        scope:  "public_profile,user_birthday,email"
        paths:
            email: email
            firstname: first_name
            lastname: last_name
            gender: gender
            birthday: birthday
            profilepicture: picture.data.url
            locale: locale
    google:
        type:                google
        client_id:           <client_id>
        client_secret:       <client_secret>
        #scope:               "user:email"
fosub:
    # try 30 times to check if a username is available (foo, foo1, foo2 etc)
    username_iterations: 30

    # mapping between resource owners (see below) and properties
    properties:
        facebook: facebook_id
        google: google_id

How do I get the values I set up the paths?

Thanks!


Solution

  • $data = $response->getResponse();
    ...
    $data["email"];
    $data["picture"]["data"]["url"];
    $data['first_name'];
    $data['last_name'];
    $data['locale'];
    

    With paths:

    $response->getEmail();
    $response->getProfilepicture();
    $response->getFirstname();
    $repsonse->getLastname();
    $repsonse->getLocale();