【问题标题】:PHP - Get post data from Facebook page using only facebook graphPHP - 仅使用 Facebook 图表从 Facebook 页面获取帖子数据
【发布时间】:2018-01-03 11:42:53
【问题描述】:

有没有办法让 Facebook 使用简单的php 将帖子的内容分页。

我需要在没有 Php-sdkFacebook API 的情况下仅使用 Facebook GraphFacebook 应用程序

【问题讨论】:

    标签: php facebook facebook-graph-api curl facebook-php-sdk


    【解决方案1】:

    我找到了解决办法

    <?php
    error_reporting(0);
    /*xxxxclient_idxxx='your clientid'*/
    /*xxxxxxclient_secretxxxx='your client_secret'*/
    //Replace "YOUR-PAGE-NAME" with your page name.
    $access_str = file_get_contents('https://graph.facebook.com/oauth/access_token?client_id=xxxxclient_idxxx&client_secret=xxxxxxclient_secretxxxx&grant_type=client_credentials');
    $tokenarr = str_replace('"','',$access_str);
    $tokenarray = explode(":",str_replace(',',':', $tokenarr));
    var_dump($tokenarray);  //Request the public posts. 
    $json_str = file_get_contents('https://graph.facebook.com/YOUR-PAGE-NAME/feed??fields=attachments&fields=attachments&access_token='.$tokenarray[1]);
    
    //decode json string into array
    
    $data = json_decode($json_str);
    
    foreach ($data as $posts) {
        foreach($posts as $post){
        $postit = (array) json_decode(json_encode($post), True);
        foreach ($postit as $getit) {
        echo '<p>' .$getit['data'][0]['description'].'</p>';
        echo '<img src="'.$getit['data'][0]['media']['image']['src'].'" />';
        echo "</br>-----------</br>";
            }
    
        }
    }
    
    ?>
    

    此脚本获取状态文本和图像

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-09-26
      • 2016-07-18
      相关资源
      最近更新 更多