使用图谱API从fb获取最新帖子 [英] getting latest posts from fb using graph api

查看:60
本文介绍了使用图谱API从fb获取最新帖子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从fb获取最新帖子,并且需要显示在我的网站上(magento).我已经在Facebook中注册了一个应用,并尝试使用url来获取帖子,但是它给出了空数组

I want to get latest posts from fb and need to display on my site(magento). I have registerd one app in facebook and try to getting posts by using the url but it's giving empty array

    require_once(Mage::getBaseDir('lib') . '/facebook/facebook.php');
    $facebook = new Facebook(array(
              'appId'  => 'xxxxxxxxxxxx',
              'secret' => 'xxxxxxxxxxxxxxxxxxxx',
            ));
    $fbid = "xxxxxxxxxx";
    $secret = "xxxxxxxxxxxxxxxxxxxxxxx";
    $token = 'https://graph.facebook.com/oauth/access_token?client_id='.$fbid.'&client_secret='.$secret.'&grant_type=client_credentials';
    $token = file_get_contents($token);
    $posts = json_decode(
                file_get_contents('https://graph.facebook.com/' . $fbid . '/feed?
                    access_token=' . $token
                )
            );

但是它给出了一个空数组,你能帮我得到结果以及为什么它给出空吗?

But it's giving an empty array and could you help me to get the results and why it is giving empty?

推荐答案

为了从Facebook读取Feed,必须将用户登录到Facebook并要求用户提供read_stream权限.

In order to read the Feed from Facebook, you must log the user into Facebook and ask the user for the read_stream permission.

该供稿将是登录用户的供稿,可能不适用于您网站的所有用户,除非您网站的每个用户看到自己的供稿...

The feed will be the logged-in user's feed and may not be appropriate for all users of your website, unless each user of your website sees their own feed...

这篇关于使用图谱API从fb获取最新帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆