I'm using one call to the Facebook Open Graph API to grab two sets of JSONP data, and having some trouble parsing the response.
Here's my code:
// The IDs to the fan pages to like
var likeURLs = ['71671905072','146175949904'];
// The base of the URL we will build to query the API
var reqURL = "http://graph.facebook.com/?ids=";
// Construct the rest of reqURL using our fan pages
for (var i=0; i < likeURLs.length; i++) {
reqURL += likeURLs[i];
if (i != (likeURLs.length - 1)) {reqURL += ',';} else {reqURL += "&callback=?"}
};
function getLikes(){
$.getJSON(reqURL, function(data){
console.dir(data);
});
}
getLikes();
The data is successfully returned, but I'm spacing on how to access it correctly. For whatever reason, data[0]
won't work, no开发者_如何转开发r will data.71671905072
. Can anybody point me towards the right syntax? It's late and my brain is not working very well.
data["71671905072"]
should work.
精彩评论