symfony - HWIOAuthBundle get birthday, gender after Facebook Login -
as per documentation able configure , store facebook id fosuserbundle entity user
i want store birthday , gender also.
app/config/config.yml
hwi_oauth: firewall_name: secured_area resource_owners: facebook: type: facebook client_id: <client_id> client_secret: <client_secret> scope: "email,user_birthday"
in documentation there description here unable work. beginner here documentation isn't helpful me.
where can facebook response contains local data.
i need store data along other fosuserbundle fields.
your config this:
facebook: type: facebook client_id: %client_id% client_secret: %client_secret% scope: "email, basic_info, user_birthday" infos_url: "https://graph.facebook.com/me?fields=id,email,first_name,last_name,gender,birthday"
then on accountconnector
service / or how handle response can this:
$data = $response->getresponse(); //check if fields set ... $user->setlastname($data['last_name']); $user->setbirthdate(new \datetime($data['birthday'])); $user->setgender($this->setgender($data['gender'])); $user->setemail($data['email']);
since facebook sends nominal values gender, have created setgender
function.
private function setgender($gender) { return ($gender === 'male') ? '1' : '0' ; }
Comments
Post a Comment