繁体   English   中英

如何从jquery中的facebook graph api获取数据

[英]how to get data from facebook graph api in jquery

我正在尝试通过jquery使用facebook graph api获取json数据。 我正在使用下面的代码。 我正在尝试使用$ .getJSON函数获取json数据,但它在萤火虫中显示此错误

NetworkError: 400 Bad Request - https://graph.facebook.com/me/home?access_token=mytoken

这是我的代码

<!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>

我在哪里犯错?

如果您转到直接发布的URL,则返回错误:

{
   "error": {
      "message": "(#606) Queries for multiple source_ids require a non-zero viewer that has granted read_stream permission",
      "type": "OAuthException"
   }
}

这意味着您需要提示read_stream权限才能读取用户供稿。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM