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

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

    protected function fetchAttributes()
	{
		$info = $this->makeSignedRequest('account/verify_credentials.json', [
            'include_email'=>1
        ]);

        $profile = [
            'id' => $info['id'],
            'email' => $info['email'],
            'name' => $info['name'],
            'locale' => $info['lang'],
        ];

		$this->attributes['id'] = $info['id'];
		$this->attributes['name'] = $info['name'];
		$this->attributes['url'] = 'http://twitter.com/account/redirect_by_id?id=' . $info['id_str'];
        $this->attributes['profile'] = $profile;
        
        $this->setSocialProfile($profile);

        return true;
	}
}
