I am developing a Spotify App and everything goes very well with a lot of reverse engineering and inspecting the javascript objects from the inspector. However, I can't seem to manage to get the Facebook connect code working.
I have tried using the Facebook Javascript FB.init()
and then FB.login but the domain is sp://myidentifier which isn't a valid domain for Facebook.
I see that other apps have managed to get this working so I am sure it works. The best way would be if there were any built in methods for doing this since Spotify is well connected to Facebook to start with?
I really appreciate any help I can get. From today I can't inspect any other apps than my own which otherwise could have put me in the right direction.
I am developing a Spotify App and everything goes very well with a lot of reverse engineering and inspecting the javascript objects from the inspector. However, I can't seem to manage to get the Facebook connect code working.
I have tried using the Facebook Javascript FB.init()
and then FB.login but the domain is sp://myidentifier which isn't a valid domain for Facebook.
I see that other apps have managed to get this working so I am sure it works. The best way would be if there were any built in methods for doing this since Spotify is well connected to Facebook to start with?
I really appreciate any help I can get. From today I can't inspect any other apps than my own which otherwise could have put me in the right direction.
Share Improve this question edited Dec 13, 2011 at 3:27 Sameera Thilakasiri 9,50810 gold badges53 silver badges87 bronze badges asked Dec 13, 2011 at 1:16 Christian LandgrenChristian Landgren 13.8k6 gold badges36 silver badges31 bronze badges 1- I just got a ment from Spotify: "I can't find this in the docs, but try something like:" sp.core.showAuthDialog(auth_url, close_url, callbacks) – Christian Landgren Commented Dec 13, 2011 at 11:22
2 Answers
Reset to default 7I was faster than Stackoverflow this time ;)
This is the code I ended up with:
var appID = "1234567890";
var path = 'https://www.facebook./dialog/oauth?';
var successUrl = "https://www.facebook./connect/login_success.html";
var queryParams = [
'client_id=' + appID,
'redirect_uri=' + successUrl,
'display=popup',
'scope=email,read_stream',
'response_type=token'
];
var query = queryParams.join('&');
var url = path + query;
sp.core.showAuthDialog(url, successUrl, {
onSuccess : function(response) {
console.log('success', response);
// response contains access token in hashstring
var queryPart = response.split("#")[1];
var queryStrings = queryPart.split("&");
accessToken = queryStrings[0].split('=')[1];
// we will use the token to get the rest of the user data
$.getJSON('https://graph.facebook./me?access_token=' + accessToken + '&callback=?', function(facebookUser){
console.log('logged in user: ', facebookUser);
// TODO: add logic to handle the user here
});
}
});
Use the auth module instead. sp.core is a private object and will not pass the approval stage for submitting an app on App Finder.
var sp = getSpotifyApi(1);
var auth = sp.require('sp://import/scripts/api/auth');
auth.authenticateWithFacebook('MY_APP_ID', ['user_about_me', 'user_checkins'], {
onSuccess : function(accessToken, ttl) {
console.log("Success! Here's the access token: " + accessToken);
},
onFailure : function(error) {
console.log("Authentication failed with error: " + error);
},
onComplete : function() { }
});
https://developer.spotify./technologies/apps/docs/beta/09321954e7.html
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744101907a4558566.html
评论列表(0条)