TJ Muehleman
TJ Muehleman

Reputation: 81

Artist info missing from Facebook Graph API /music.listens endpoint

I'm playing around w/ the /me/music.listens endpoint of Graph API and I have it working just fine. Except I can't seem to figure out how to get actual artist info to come back. I see the song and even the album (though that seems a little inconsistent too). But never any artist info.

Check the developer explorer here: https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Fmusic.listens

No artist info. Is this just not returned? I can't see how to specify this in a fields param list. FB's documentation of the actions is spotty at best so I figured I'd try here.

Thanks!

Upvotes: 2

Views: 661

Answers (3)

Daniel Bowden
Daniel Bowden

Reputation: 988

Old question I know, but you can retrieve related information such as both the song title and artist title in the same request using Graph API's 'field expansion'.

For example - Last 10 songs

me?fields=music.listens.limit(10){data{song{title,id},musician{id,title}}}

To retrieve more information from either the song or musician entities just tweak the fields requested.

Note, this requires user_actions.music permission

Upvotes: 0

r.flipo
r.flipo

Reputation: 135

You can retrieve artists informations on graph API with the song id :

https://graph.facebook.com/song_id?fields=data{musician}

ex : https://graph.facebook.com/697975930266172?fields=data{musician}

Upvotes: 1

TJ Muehleman
TJ Muehleman

Reputation: 81

I've figured out a work around. It doesn't look like Facebook actually returns artist info. So you have to use the Spotify Lookup Service (http://developer.spotify.com/technologies/web-api/lookup/).

To break it down a little further, you start by pulling the music.listens feed from FB and you'll get info that looks like:

                 (
                   [song] => Array
                        (
                         [id] => 381659191902248
                         [url] => http://open.spotify.com/track/**2Vv27Gc5k5GgGW9jgtj1CS**
                         [type] => music.song
                         [title] => Follow Through
                        )
                    )

From there, you need to grab the bolded track ID.

Lastly, fetch the song metadata with this call to Spotify: http://ws.spotify.com/lookup/1/.json?uri=spotify:track:2Vv27Gc5k5GgGW9jgtj1CS

You'll be returned the album name, artist info, etc.

If someone knows a better way, lemme know!

Upvotes: 1

Related Questions