/** * Update Google OAuth information for user * * @return void * @author **/ public function updateOAuthAccount($user, $gUserData) { $response = $this->client->getAccessToken(); $scope = $this->scopes; $actual_response = $response; $response = json_decode($response); $oauth = OAuthAccount::firstOrCreate(array('user_id' => $user->id, 'provider' => 'youtube', 'channel' => $gUserData['channel'])); $oauth->image_url = $gUserData['image']; $oauth->url = $gUserData['url']; $oauth->uid = $gUserData['uid']; $oauth->channel = $gUserData['channel']; $oauth->username = $gUserData['username']; $oauth->access_token = $response->access_token; if (isset($response->refresh_token)) { $oauth->refresh_token = $response->refresh_token; } if (isset($response->created)) { $oauth->created = $response->created; } $oauth->expires_in = $response->expires_in; $oauth->signature = serialize($actual_response); if (!is_array($scope)) { $scope = (array) $scope; } $scopes = array(); foreach ($scope as $s) { $scopes['google.' . $s] = 1; } $oauth->scopes = $scopes; $oauth->save(); return true; }
/** * undocumented function * * @return void * @author **/ public function updateOAuthAccount($user, $userData) { $scope = $this->scopes; $oauth = OAuthAccount::firstOrCreate(array('user_id' => $user->id, 'provider' => 'facebook')); $oauth->access_token = $userData['access_token']; $oauth->uid = $userData['uid']; $oauth->location = $userData['location']; $oauth->url = $userData['url']; $oauth->username = $userData['username']; if (isset($userData['image_url'])) { $oauth->image_url = $userData['image_url']; } if (!is_array($scope)) { $scope = (array) $scope; } $scopes = array(); foreach ($scope as $s) { $scopes['facebook.' . $s] = 1; } $oauth->scopes = $scopes; $oauth->save(); return true; }