properties - How to check if a property exists (FB auth) with Laravel Oauth2 -


i have authentication system facebook login in laravel works fine when user of properties logs in, when user doesn't have 1 of properties filled out, throws error (for example):

undefined property: stdclass::$bio

here relevant code:

facebook.php:

public function get_user_info(token_access $token)     {         $url = 'https://graph.facebook.com/me?'.http_build_query(array(             'access_token' => $token->access_token,         ));          $user = json_decode(file_get_contents($url));          // create response request         return array(             'uid' => $user->id,             'nickname' => $user->username,             'name' => $user->name,             'first_name' => $user->first_name,             'last_name' => $user->last_name,             'gender' => $user->gender,             'email' => $user->email,             'birthday' => $user->birthday,             'location' => $user->location->name,             'description' => $user->bio, //the line giving trouble user             'friends'  => 'https://graph.facebook.com/me/friends?fields=id&access_token='.$token->access_token,             'image' => 'https://graph.facebook.com/me/picture?width=200&height=200&access_token='.$token->access_token,             'urls' => array(             'facebook' => $user->link,             ),         );     } 

oauth2controller.php:

if(is_null($check)) {                    $fan = new fan;                    $fan->fbid = $user['uid'];                   $fan->email = $user['email'];                   $fan->first_name = $user['first_name'];                   $fan->last_name = $user['last_name'];                   $fan->gender = $user['gender'];                   $fan->birthday = $user['birthday'];                   $fan->age = $age;                   $fan->city = $city;                   $fan->state = $state_abbrev;                   $fan->image = $user['image'];                   $fan->friend_ids_url = $user['friends'];                   $fan->friend_ids_unpacked = $friend_ids;                    $fan->save();                    $new = fan::where('fbid', '=', $user['uid'])->first();                    auth::login($new);                   return redirect::to('fans/home');                  } 

how check user has these fields included profile, don't have error thrown? thank you.

can this?

 'description' => (isset($user->bio) ? $user->bio : null) 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -