Reputation: 621
I'm implementing the Graph API in Facebook to retrieve data as JSON from an "https" site.
I'm using the following code
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
var accessToken = response.authResponse.accessToken;
document.getElementById("statusCheck").innerHTML = accessToken;
$.getJSON('https://graph.facebook.com/me/friends?access_token=' . accessToken,
function(dataJSON){
//The rest
});
}
});
After this failed I tried to use $.ajax with no datatype specification and parsing the data with $.parseJSON but no information is retrieved at all
My question is really twofold: Is my JSON retrieval the problem or is it the fact that the protocol is "https"? If it is not possible to use getJSON on an external https protocol, how can I recover the hash of the Facebook friends?
Upvotes: 1
Views: 641
Reputation: 764
your code is working. just use +(plus) instead .(dot) before accesstoken.
$.getJSON('https://graph.facebook.com/me/friends?access_token=' **+** accessToken,
function(dataJSON){
console.log(dataJSON);
});
Upvotes: 1