简体   繁体   English

Facebook Graph API 用于拉取新闻提要。 替换已停产的 RSS/XML

[英]Facebook Graph API to Pull News Feed. Replace discontinued RSS/XML

OK, Since facebook has discontinued their RSS feed for their news feed.好的,因为 facebook 已经停止了他们的新闻提要的 RSS 提要。 I've been trying to figure out how to use Graph API to pull the newsfeed in. I've been searching but i can not find anything.我一直在试图弄清楚如何使用 Graph API 来拉入新闻源。我一直在搜索,但找不到任何东西。 Am I doing this right?我这样做对吗? Tried going through the developer.fb docs but can't seem to get it right.尝试浏览 developer.fb 文档,但似乎无法正确理解。 What am I doing wrong?我究竟做错了什么? This is what I've done: I created an App in developer.fb.这就是我所做的:我在 developer.fb 中创建了一个应用程序。 enabled user_feed, read_stream (yes i know it is being deprecated), and user_status.启用 user_feed、read_stream(是的,我知道它已被弃用)和 user_status。 I've also enabled it or made it live.我也启用了它或让它上线。 All i want to do is put the news feed on another website.我想要做的就是将新闻提要放在另一个网站上。

My code is as followed (tried two methods):我的代码如下(尝试了两种方法):

` Open Graph rss ` 打开图表 rss

</head>
<body>
    <script>
        window.fbAsyncInit = function() {
            FB.init({
                appId      : 'MyAppID',
                xfbml      : true,
                version    : 'v2.4'
            });
        };

        (function(d, s, id){
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) {return;}
            js = d.createElement(s); js.id = id;
            js.src = "//connect.facebook.net/en_US/sdk.js";
            fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));
    </script>

    <script>
        function feed() {
            FB.api(
                "/me/feed",
                function (response) {
                    if (response && !response.error) {
                        document.write('are we here?'); //no
                        document.write(response.data.message);
                    }
                }
            );   
        }



        function feed2(){

            var page_id = 'my_pageID';  //Also tried appid
            var pageaccessToken='MyAppToken';

            FB.api('/' + $page_id + '/feed?access_token=' + pageaccessToken, function(response){
                document.write("am i here?"); // does not get here
                if (response && response.data && response.data.length){
                    var ul = document.getElementById('pagefeed');
                    for (var j=0; j < response.data.length; j++){
                        var feed = response.data[j];
                        document.write(feed.message);
                        document.write(feed.link);
                    }
                }
            });
        }

    </script>


    <button onclick="feed()">test</button> 
    <button onclick="feed2()">feed</button>

</body>

` `

Just for your information.仅供参考。 You actually CAN view your pages feed and it's very very simple:您实际上可以查看您的页面提要,这非常简单:

https://graph.facebook.com/ {Page-ID}/posts?access_token={access-Token} https://graph.facebook.com/ {Page-ID}/posts?access_token={access-Token}

You need to create a graph API app to get an access token.您需要创建一个图形 API 应用程序来获取访问令牌。 but it's possible但有可能

check it:核实:

http://johndoesdesign.com/blog/2011/php/adding-a-facebook-news-status-feed-to-a-website/ http://johndoesdesign.com/blog/2011/php/adding-a-facebook-news-status-feed-to-a-website/

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

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