<?php
namespace common\modules\eauth\components;

class FacebookOAuth2Service extends \nodge\eauth\services\FacebookOAuth2Service
{
    use ServiceTrait;

    protected function fetchAttributes()
	{
		$info = $this->makeSignedRequest('me', [
            'query' => [
                'fields' => join(',', [
                    'email',
                    'id',
                    'name',
                    'link',
                    'last_name',
                    'first_name',
                    'locale',                  
                    'picture',
                    'verified',
                    'gender',
                ]),
            ]
        ]);

        $profile = [
            'id' => $info['id'],
            'email' => $info['email'],
            'name' => $info['name'],
            'locale' => $info['locale'],
        ];
        
        $this->attributes['id'] = $info['id'];
		$this->attributes['name'] = $info['name'];
		$this->attributes['url'] = $info['link'];
        $this->attributes['profile'] = $profile;

        $this->setSocialProfile($profile);

        return true;
	}
}
