Skip to content
Snippets Groups Projects

Resolve "Fix call on /me when logged in from facebook"

Merged Benoît Harrault requested to merge 34-fix-call-on-me-when-logged-in-from-facebook into master
3 files
+ 32
15
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 21
4
@@ -27,8 +27,8 @@ if ($_SESSION['accessToken']) {
}
$options = [
'scope' => $SPOTIFY_REQUIRED_SCOPES,
'auto_refresh' => true,
'scope' => $SPOTIFY_REQUIRED_SCOPES,
'auto_refresh' => true,
];
$api = new SpotifyWebAPI\SpotifyWebAPI($options, $session);
@@ -39,7 +39,24 @@ $_SESSION['refreshToken'] = $session->getRefreshToken();
// ################################################################
$user = $api->me();
$user = [
'id' => '',
'image_url' => '',
'display_name' => '',
'profile_url' => '',
];
try {
$me = $api->me();
$user = [
'id' => $me->id,
'image_url' => \count($me->images) ? $me->images[0]->url : '',
'display_name' => $me->display_name,
'profile_url' => $me->external_urls->spotify,
];
} catch (Exception $ex) {
error_log($ex->getMessage());
}
$topArtistsCount = 40;
$playlistsCount = 24;
@@ -197,7 +214,7 @@ if ($generatePlaylistFromPlaylist) {
$templateData['playlist'] = createDisplayablePlaylist($newPlaylist);
} else {
$templateData['topArtists'] = $api->getMyTop('artists', ['limit' => $topArtistsCount, 'time_range' => 'short_term'])->items;
$templateData['playlists'] = $api->getUserPlaylists($user->id, ['limit' => $playlistsCount])->items;
$templateData['playlists'] = $api->getUserPlaylists($user['id'], ['limit' => $playlistsCount])->items;
}
require '../template.php';
Loading