简体   繁体   中英

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

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

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> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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