使用Graph API从公开的Facebook页面获取墙壁信息 - 这真的是复杂的吗? [英] Get wall feed from a public Facebook page using Graph API - is it really this complex?

查看:982
本文介绍了使用Graph API从公开的Facebook页面获取墙壁信息 - 这真的是复杂的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始阅读向非Facebook用户显示Facebook帖子这是一些有用的,但我不敢相信这是很难从Facebook获取公共饲料。

I have started off by reading Displaying Facebook posts to non-Facebook users which is of some use but I cannot believe it is this difficult to get a public feed from Facebook.

我想要一个饲料的页面是公开的,你不需要登录到它。

The page I want a feed from is public, you do not need to be logged into get to it.

我假定我需要一个access_token来获取这些信息,尝试访问URL,而没有结果一个OAuth错误。

Am I right in presuming that I need an access_token to get to this information, attempting to access the URL without results in an OAuth error.

所以流程应该是这样(大量,过于复杂):

So the flow should be like this (massively, overly complex):


  1. 使用用户进行身份验证(如果用户不在Facebook上怎么办?)

  2. 一些复杂的OAuth废话 - 只是为了阅读Feed,我甚至不想要按钮或发布到墙壁功能

  3. 使用用户的access_token
  4. $ b $ li 使用PHP请求获取正确的URL的Feed
  1. Authenticate using a user (what if the user isn't on Facebook?)
  2. Some complex OAuth nonsense - just to read the feed, I do not even want a like button or post to wall functionality
  3. Get the feed using a PHP request to the correct URL with the user's access_token
  4. Render the feed

假设用户不在Facebook上,您该怎么做,使用通用应用程序获取Feed?

Assuming the user isn't on Facebook, what do you do, use a generic app to get the feed?


  1. 使用我的通用应用程序的ID和密码对Facebook进行认证请求。

  2. 某些复杂的OAuth废话

  3. 使用PHP请求获取Feed使用应用程序的access_token的正确URL

  4. 渲染Feed

  5. 哦,不,auth已过期,重新认证并捕获这个新的access_token以供使用在未来的请求中。

  1. Hardcode an auth request to Facebook using my generic app's ID and secret
  2. Some complex OAuth nonsense
  3. Get the feed using a PHP request to the correct URL with the app's access_token
  4. Render the feed
  5. Oh no, the auth has expired, re-auth and capture this new access_token for use in future requests.

这似乎非常复杂,除了Facebook要知道一切正在发生之外,没有任何理由使用XPath更容易做一个cURL并从公共URL中删除内容。

This seems really complex for no reason other than Facebook wants to know EVERYTHING that is going on, it'd be easier to do a cURL and scrape the content from the public URL using XPath.

任何有关这方面的帮助都会很棒。

Any help on this would be great.

谢谢,
Jake

Thanks, Jake

编辑

一个编辑显示这不是一个确切的重复。

我有一个access_token的工作,但现在它失败了, ken已过期,我无法再使用它从公共墙壁获取信息。

I had this working with an access_token in place, but now it fails, the token has expired and I can no longer use it to obtain information from the public wall.

我尝试使用其他帖子中提到的方法来扩展此令牌的到期日期但是这没有起作用,而且到期时间也没有延长 - 我们现在在这里,使用无效的令牌,而且没有进一步的。

I attempted to extend the expiration date of this token using the methods mentioned in other posts but this didn't work and the expiration was not extended - we are now here, with an invalid token and no further along.

似乎手动进程批准OAuth请求意味着无法以编程方式获取公共页面的Feed。

It seems that the manual process of having to approve the OAuth request means that it is impossible to programatically get the feed of a public page.

推荐答案

两年后,您可以使用Facebook应用程序(使用PHP和Slim的示例)以编程方式执行此操作: https://developers.facebook.com / apps /

Two years later, you can programmatically do this with a Facebook App (an example using PHP and Slim): https://developers.facebook.com/apps/

$base_api="https://graph.facebook.com/";
$client_id="XXXXXX";
$app_secret="XXXXXX";

//get a profile feed (can be from a page, user, event, group)
$app->get('/feed/:profileid/since/:start_date', function ($profile_id,$start_date) {

    $start_time=date('m/d/Y h:i:s',$start_date);

    $request = new FacebookRequest(
      getSession(),
      'GET',
      '/'.$profile_id.'/feed?since='.$start_time
    );

    $response = $request->execute();
    $graphObject = $response->getGraphObject();

    //do something with $graphObject

});


function getSession(){
    $session = new FacebookSession(getAccessToken());
    return $session;
}


function getAccessToken(){
    global $base_api, $client_id, $app_secret;
    $url=$base_api."oauth/access_token?client_id=".$client_id."&client_secret=".$app_secret."&grant_type=client_credentials";
    $str = file_get_contents($url);
    $token = str_replace ( "access_token=" , "" , $str );
    return $token;
}

这篇关于使用Graph API从公开的Facebook页面获取墙壁信息 - 这真的是复杂的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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