简体   繁体   English

http Graph不能从我的fb页面返回我的留言,但是使用fbFetch()和JSON可以正常工作

[英]http Graph is Not Returning my Wall Posts From my fb page, but with fbFetch() and JSON it works fine

Retrieving my Own Wall Posts trough fbFetch() and JSON works fine, but trying to retrieve using Php and Curl is not giving me nothing.. 通过fbFetch()和JSON检索我自己的墙上帖子可以正常工作,但是尝试使用Php和Curl检索却无济于事。

But if i use fb page id from another fb page with the same script show me all his posts.. 但是,如果我从另一个具有相同脚本的fb页面使用fb页面ID,请向我展示他的所有帖子。

And another crazy thing is that the same Php Curl works fine in localhost mode, and give me all my facebook posts.. 另一个疯狂的事情是,相同的Php Curl在localhost模式下可以正常工作,并把我所有的Facebook帖子都给我。

Have anybody an idea what happens ? 有人知道会发生什么吗? Is there a trick to solve this issue ? 有解决这个问题的技巧吗?

I really want to use PHP curl, not JSON.. 我真的想使用PHP curl,而不是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 另一个人有同样的麻烦,但任何人响应他的问题的Facebook的Open Graph喂不回到我所有的墙贴从我

Ifaour: 如果:

Well, here is the PHP that works as the follows: 好吧,这是PHP,其工作方式如下:

-Retrieve Posts of any fb page id -> OK -检索任何fb页面ID的帖子->确定

-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: AND这是Javascript JSON,其工作方式如下:

-Retrieve Posts of any fb page id -> OK -检索任何fb页面ID的帖子->确定

-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> 

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

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