Can you get a public Facebook page's feed using Graph API without asking a user to allow?

前端 未结 6 1004
遥遥无期
遥遥无期 2020-11-29 17:00

I\'ve never used Facebook\'s Graph API, or OAuth. I\'m simply trying to get a public Facebook page\'s feed using the Graph API, but it requires an access token. I don\'t wan

6条回答
  •  天涯浪人
    2020-11-29 17:26

    Facebook app access token doesn't ever expire or change unless I manually reset the secret

    That's correct.

    App tokens do not expire unless the App Secret is reset. App access tokens are unique to each app.

    Since public feeds take any valid access token, application tokens can be used.

    Go to https://developers.facebook.com/tools/access_token and you would not require a flow. Then you can just hard code it in. The moment you reset the secret this method is void.

    $access_token = '1111111111|2Cha_1-n5'
    $graph_url = "https://graph.facebook.com/Boo/posts?access_token=" 
        . $access_token;
    $page_posts = json_decode(file_get_contents($graph_url), true);
    

    Then iterate through the pages

    foreach($page_posts['data'] as $post){
        $post_link = $post['actions'][0]['link'];
        $page_id = $post['from']['id'];
        $page_name = $post['from']['name'];
        $message = ($post['message']) ? $post['message'] : " ";
        $name = ($post['name']) ? $post['name'] : " ";
        $story = ($post['story']) ? $post['story'] : " ";
        $post_time = $post['updated_time'];
    }
    

    Source: http://philippeharewood.com/facebook/how-to-get-facebook-access-tokens-in-php-for-public-posts-the-basic-sauce/

提交回复
热议问题