drm30963 2014-02-12 20:02
浏览 48

facebook me / home不显示数据

Hey all i am trying to get a news feed (home feed) but this doesnt seem to work:

<?php
require '../src/facebook.php';

$facebook = new Facebook(array(
  'appId'  => 'XXXXXXXXXXXXXXXX',
  'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  'fileUpload' => true,
  'cookie' => true
));

$user = $facebook->getUser();

if ($user) {
  try {
    $user_profile   = $facebook->api('/me');
    $access_token = $facebook->getAccessToken();    
    $feed           = $facebook->api('/me/home?access_token=' . $access_token);
    print_r($feed);

etc etc....

If i comment out the $feed and also print_r($feed) line then it works and displays my user information. However, leaving it un-commented out seems to stop it from proceeding to display other things.

I have also tried:

$feed           = $facebook->api('/me/home);

and that still produces nothing.

For my app center permissions, i have set the permissions needed to do this (read_stream) among others.

What am i missing?

enter image description here

  • 写回答

2条回答 默认 最新

  • duanbi3151 2014-02-12 20:26
    关注

    I think the best option is to use GRAPH API :

    `$graphURL = https://graph.facebook.com/$current_user_id/home?access_token=$user_access_token.`
    

    You can use curl to get the details .Example curl function is

    function curl_get_file_contents($URL) {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $URL);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,0); 
     curl_setopt($ch, CURLOPT_TIMEOUT, 400);
     $contents = curl_exec($ch);
     $err  = curl_getinfo($ch,CURLINFO_HTTP_CODE);
     curl_close($ch);
    $contents=json_decode($contents,true);
     if ($contents) return $contents;
     else return FALSE;
    

    }

    Ex:- $user_home = curl_get_file_contents($graphURL);

    评论

报告相同问题?

悬赏问题

  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)