Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7411669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:25:22+00:00 2026-05-29T06:25:22+00:00

I need to read, from a server, the stream of a specific fan page.

  • 0

I need to read, from a server, the stream of a specific fan page.
I tried to read the graph api
https://graph.facebook.com//feed?access_token=&limit=100
and it works.
What I need is to understand if the token will expire and how to renew it programmatically.
Now I generate my token through the http://developers.facebook.com/tools/explorer/ app.
Can you please help me?
I’m using the PHP sdk
thanks,
a.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:25:23+00:00Added an answer on May 29, 2026 at 6:25 am

    You can read the facebook page using below codes and you can also get the specified fields

    https://graph.facebook.com/$page_id/?fields=link,etc&access_token=page_access_token
    

    or

    $response = $fb->api($page_id .  '/?fields=link,etc&'. $access_token, 'GET')
    

    Below is the solution for four scenarios

    1.The token expires after expires time (2 hours is the default).
    2.The user changes her password which invalidates the access token.
    3.The user de-authorizes your app.
    4.The user logs out of Facebook.

    To ensure the best experience for your users, your app needs to be prepared to catch errors for the above scenarios. The following PHP code shows you how to handle these errors and retrieve a new access token.

    When you redirect the user to the auth dialog, the user is not prompted for permissions if the user has already authorized your application. Facebook will return you a valid access token without any user facing dialog. However if the user has de-authorized your application then the user will need to re-authorize your application for you to get the access_token.

    <?php
    $app_id = "YOUR_APP_ID";
    $app_secret = "YOUR_APP_SECRET"; 
    $my_url = "YOUR_POST_LOGIN_URL";
    
    // known valid access token stored in a database 
    $access_token = "YOUR_STORED_ACCESS_TOKEN";
    
    $code = $_REQUEST["code"];
    
    // If we get a code, it means that we have re-authed the user 
    //and can get a valid access_token. 
    if (isset($code)) {
    $token_url="https://graph.facebook.com/oauth/access_token?client_id="
      . $app_id . "&redirect_uri=" . urlencode($my_url) 
      . "&client_secret=" . $app_secret 
      . "&code=" . $code . "&display=popup";
    $response = file_get_contents($token_url);
    $params = null;
    parse_str($response, $params);
    $access_token = $params['access_token'];
    }
    
    
    // Attempt to query the graph:
    $graph_url = "https://graph.facebook.com/me?"
    . "access_token=" . $access_token;
    $response = curl_get_file_contents($graph_url);
    $decoded_response = json_decode($response);
    
    //Check for errors 
    if ($decoded_response->error) {
    // check to see if this is an oAuth error:
    if ($decoded_response->error->type== "OAuthException") {
      // Retrieving a valid access token. 
      $dialog_url= "https://www.facebook.com/dialog/oauth?"
        . "client_id=" . $app_id 
        . "&redirect_uri=" . urlencode($my_url);
      echo("<script> top.location.href='" . $dialog_url 
      . "'</script>");
    }
    else {
      echo "other error has happened";
    }
    } 
    else {
    // success
    echo("success" . $decoded_response->name);
    echo($access_token);
    }
    
    // note this wrapper function exists in order to circumvent PHP’s 
    //strict obeying of HTTP error codes.  In this case, Facebook 
    //returns error code 400 which PHP obeys and wipes out 
    //the response.
    function curl_get_file_contents($URL) {
    $c = curl_init();
    curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($c, CURLOPT_URL, $URL);
    $contents = curl_exec($c);
    $err  = curl_getinfo($c,CURLINFO_HTTP_CODE);
    curl_close($c);
    if ($contents) return $contents;
    else return FALSE;
    }
    ?>
    

    for more details info you can visit this link
    Thanks

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Actually in one of my project i need to read images from remote server
I have a server link from where I need to read the pdf content.
I need to stream a file from my server to several clients. I'm not
I need to read from and write to Excel spreadsheets using Delphi 2010. Nothing
I need to read from either an array or a file (preferably a file
I have a database table with a field that I need to read from
I need to read data from XML to a List<>. The XML file contains
I need to read data from a legacy database file produced by Visual Basic
I am developing an android application and i need to read words from a
As part of an assignment, I need to read data from a binary file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.