1

我正在建立一个应该从 facebook 检索新闻源的网站。然而,我的脚本最终在 Newsfeed 部分什么也没有显示。我目前在我的母版页标题中使用此代码:

<script src="http://code.jquery.com/jquery.min.js"></script>
<script>
    $(document).ready(function () {
        $.getJSON('http://graph.facebook.com/pyrotltu?fields=posts.limit(10).fields(message,picture,link,name,caption,description,likes,comments.fields(from,message,like_count,id),created_time,id)&callback=?', function (fbResults) {
            $.each(fbResults.data, function () {
                $('<article class="News"></article>').append(
                    '<div class="fbmessage">' + this.message + '</div>'
                    + '<a href="' + this.link + '">' + '<div class="fblink">' + '<img class="fbpicture" src="' + this.picture + '" height="90" width="90" alt="' + this.name + '" />' + '<div class="fbname">' + this.name + '</div>' + '<div class="fbcaption">' + this.caption + '</div>' + '<div class="fbdescription">' + this.description + '</div>' + '</div>' + '</a>'
                    + '<div class="fbcount">' + this.likes.count + '</div>'
                    + '<time class="fbtime" datetime=">' + this.created_time + '">' + this.created_time + '&middot;</time>'
                    + '<iframe class="fblike" src="http://www.facebook.com/plugins/like.php?href=' + this.link + '" ></iframe>'
                    + '<div class="fbcomments"></div>'
                        + $.each(fbResults.data.comment.data, function () {
                            $('<div class="Comments"></div>').append(
                            '<img class="fbcommentpic" src="https://graph.facebook.com/' + this.from.id + '/picture" height="50" width="50" alt="' + this.from.name + '" />'
                            + '<div class="fbcommentname"><a href="http://www.facebook.com/' + this.from.id + '">' + this.from.name + '</a></div>'
                            + '<div class="fbcommentmessage">' + this.message + '</div>'
                            + '<div class="fblike_count">' + this.like_count + '</div>'
                            ).appendTo('.fbcomments');
                        })
                 ).appendTo('.Newsfeed');
            })
        })
    });
</script>

要获取我使用的访问令牌:

protected void Page_Load(object sender, EventArgs e)
{

    string appId = ConfigurationManager.AppSettings["facebook:AppID"];
    string appSecret = ConfigurationManager.AppSettings["facebook:AppSecret"];

    var fb = new Facebook.FacebookClient();

    dynamic tokenInfo =
      fb.Get(
        String.Format(
          "/oauth/access_token?client_id={0}&client_secret={1}&grant_type=client_credentials",
          appId,
          appSecret));

    var appAccessToken = (string)tokenInfo.access_token;

}

(ID 和密码存储在我的 Web.config 中)

这段代码有什么遗漏或错误?

4

0 回答 0