0

I have a question!

I implemented facebook login with socialize. I tried to get facebook image but when i display it , it is a small image (100*100) and a blurred one.

Is there any way to get the real image ?

Code

 public function handleFacebookCallback()
    {
        $driver = Socialite::driver('facebook')
            ->fields([
                'name',
                'first_name',
                'last_name',
                'email',
                'gender',
                'verified',
            ]);


        $userSocial = $driver->user();


        $finduser = User::where('facebook_id', $userSocial->id)->first();

        if($finduser)
        {
            Auth::login($finduser);
            return redirect()->route('home');
        }

        else
            {
                if(!empty($userSocial->getAvatar()))
                {

                    $fileContents = file_get_contents($userSocial->getAvatar());
                    File::put(storage_path('app/public/thumbs') .'/'. $userSocial->getId() . ".jpg", $fileContents);


                }
                $imageUrl = $userSocial->getId() . ".jpg";





                $new_user = User::create([
                        'name'      => $userSocial->user['first_name'],
                        'surname'      => $userSocial->user['last_name'],
                        'email'      => $userSocial->email,
                        'facebook_id'=> $userSocial->id,
                        'image'=>$imageUrl,

                    ]);
                    Auth::login($new_user);
                    return redirect()->route('home');
            }
    }
Alphal1111
  • 99
  • 3
  • 13

1 Answers1

0

When you get the the avatar $userSocial->getAvatar(); it have a link to facebook, where the type parameter is set to normal.

https://graph.facebook.com/v2.6/XXXXFBUSERIDXXXX/picture?type=normal

Change that to large

https://graph.facebook.com/v2.6/XXXXFBUSERIDXXXX/picture?type=large

The valid options are:

small, normal, album, large, square
Vidal
  • 2,605
  • 2
  • 16
  • 32