I am trying to get json data using facebook graph api through jquery. I am using the code below. I am trying to get json data using $.getJSON function but it displays this error in firebug
NetworkError: 400 Bad Request - https://graph.facebook.com/me/home?access_token=mytoken
here is my code
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src开发者_如何转开发="http://code.jquery.com/jquery-latest.js">
</script>
<script type="text/javascript" src="script/script.js"></script>
<script>
$(function(){
//$('fb').fbWall();
var url = "https://graph.facebook.com/me/home?access_token=mytoken";
var html = "<ul>";
$.getJSON(url, function(json){
//console.log(json);
$.each(json.data, function(i,fb){
html += "<li>" + fb.id + "</li>";
});
});
html += "</ul>";
$('.fb').animate({opacity: 0}, 500, function() {
$('.fb').html(html);
});
$('.fb').animate({opacity:1}, 500);
});
</script>
<!-- <link type="text/css" rel="stylesheet" href="styles.css" /> -->
<style>
.fb {
width: 400px; height: 400px;
border:1px solid red;
}
</style>
<title>title</title>
</head>
<body>
<div class="fb">
</div>
</body>
</html>
where am I making mistake?
If you go to the URL you posted directly, it is returning the error:
{
"error": {
"message": "(#606) Queries for multiple source_ids require a non-zero viewer that has granted read_stream permission",
"type": "OAuthException"
}
}
It means you need to prompt for read_stream permission to read the users feed.
精彩评论