dongwei1234 2011-03-01 06:38
浏览 66

http图表没有返回我的墙帖从我的fb页面,但使用fbFetch()和JSON它工作正常

Retrieving my Own Wall Posts trough fbFetch() and JSON works fine, but trying to retrieve using Php and Curl is not giving me nothing..

But if i use fb page id from another fb page with the same script show me all his posts..

And another crazy thing is that the same Php Curl works fine in localhost mode, and give me all my facebook posts..

Have anybody an idea what happens ? Is there a trick to solve this issue ?

I really want to use PHP curl, not JSON..

thanks to anyone who can help on this.

Another person had the same trouble but anybody response his question Facebook Open Graph Feed Not Returning All My Wall Posts From Me

  • 写回答

1条回答 默认 最新

  • dongqiao0953 2011-03-01 15:52
    关注

    Ifaour:

    Well, here is the PHP that works as the follows:

    -Retrieve Posts of any fb page id -> OK

    -Retrieve my own Posts only in localhost mode -> OK

    -Retrieve my own Posts via my website online -> NO

    //function to retrieve posts wall
    function loadFB($idpage)
    {
        $fbID=$idpage;
    
         $graph="http://graph.facebook.com/".$idpage."/posts?limit=5";
    
         $c = curl_init($graph);
         curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
    
         $page = json_decode(curl_exec($c));
    
         curl_close($c);
    
         return $page->data;
    }
    
    $fbid='260323319978';
    
    $fbCount=0;
    
    
    $myPosts=loadFB($fbid);
    
    date_default_timezone_set("America/Buenos Aires");
    foreach($myPosts as $dPost)
    {
        if($dPost->from->id==$fbid)
         {
            $dTime = strtotime($dPost->created_time);
    
              $myTime=date("d M Y h:ia",$dTime);
    
    
              echo $mensaje=$dPost->message;
    
    
              echo $fotolink=$dPost->link;
    
              echo $foto=$dPost->picture;
    
    
              echo $post_likes=$dPost->likes->count;
    
              $permalink=$dPost->id;
              $permalink=split('_',$permalink);
              echo $perma=$permalink[1];
    
              $fbCount++;
    
              if($fbCount >= $fbLimit) break;  
    
         }
    
    }
    
    ?>
    

    AND here is the Javascript JSON that works as the follows:

    -Retrieve Posts of any fb page id -> OK

    -Retrieve my own Posts only in localhost mode -> OK

    -Retrieve my own Posts via my website online -> OK

    <script type="text/javascript" src="../js/jquery.js"></script>
    <script type="text/javascript">
    
      function fbFetch(){
    
          var url = "http://graph.facebook.com/260323319978/posts?filter=1&limit=5";   
    
            $.getJSON(url,function(json)
            {
                   var html = "<ul>";
    
                    $.each(json.data,function(i,fb)
                    {
                        var fecha=fb.created_time.split("T"); 
                        var trozos=fecha[0].split("-");
                        var mes;
                        switch(trozos[1])
                        {
        case '01': 
        mes='Enero'
        break;
        case '02': 
        mes='Febrero'
        break;
        case '03': 
        mes='Marzo'
        break;
        case '04': 
        mes='Abril'
        break;
        case '05': 
        mes='Mayo'
        break;
        case '06': 
        mes='Junio'
        break;
        case '07': 
        mes='Julio'
        break;
        case '08': 
        mes='Agosto'
        break;
        case '09': 
        mes='Setiembre'
        break;
        case '10': 
        mes='Octubre'
        break;
        case '11': 
        mes='Noviembre'
        break;
        case '12': 
        mes='Diciembre'
        break;
                        }
                        var permalink=fb.id;
                        var permalink=permalink.split("_");
                        var perma=permalink[1];
                        var pic=""+fb.picture+"";
    
    
    
    
               html += "<li id='li'><div style='font-size:11px; color:#af1e1b; margin-bottom:4px;'>"+ trozos[2] +" de "+ mes +" del "+ trozos[0] + "</div><div style='color:#72697e;'>" + fb.message + "</div><br>"+ img +"</li>"; 
                    });
    
                    pic="";
                    perma="";
    
                html += "</ul>";
    
    
    
                $('.facebookfeed').animate({opacity:0}, 500, function(){
    
                        $('.facebookfeed').html(html);
    
                                                                      });
    
                $('.facebookfeed').animate({opacity:1}, 500);
    
            });
    
    
        };
    
    
        </script>
    <body onLoad="fbFetch()">
    
    
            <div class="facebookfeed">
    
            </div> 
    
    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集