Hey everyone! I’m working on a Spotify app and I’m stuck. I want to add a feature where users can share stuff on their Facebook walls directly from the app. Since Spotify uses Facebook for login, I thought this would be easy. But I haven’t figured out how to make it happen!
I’ve been checking the Spotify API documentation and searching online without any success. Does anyone know if it’s possible to post on a Facebook wall from within the Spotify app? If it works, what API calls should I use?
I came up with something like this but I’m not sure if it’s right:
function shareOnFacebook(textContent) {
// Retrieve the Facebook token for the current user
const token = retrieveFBToken();
// Call the Facebook API to share the post
FB.api('/me/feed', 'POST',
{ message: textContent, access_token: token },
function(apiResponse) {
if (!apiResponse || apiResponse.error) {
console.error('Failed to share the post on Facebook');
} else {
console.log('Successfully shared the post on Facebook');
}
}
);
}
Any suggestions or help would be greatly appreciated. Thanks a lot!