learningtech
learningtech

Reputation: 33715

Facebook API how to get all wall items

I am having trouble getting all the facebook posts, message, photos etc... that show up on my wall via the Facebook API. Basically, many items are missing in the result set. I tried the following with FQL:

 $facebook = new Facebook(array(
                'appId' => FB_APPID,
                'secret' => FB_SECRET,
                'cookie' => true
      ));
      $fql = "SELECT post_id, actor_id, target_id, message FROM stream WHERE source_id =me() ORDER BY updated_time DESC";

   //Create Query
   $params = array(
       'method' => 'fql.query',
       'query' => $fql,
   );
   //Run Query
   $result = $facebook->api($params);

But this feed seems to be missing some items, and i don't know why.

I also tried with reading the graph feed at http://graph.facebook.com/me/feed?access_token=<Access+token> and again, i also don't get all the feed items.

What is the problem? Why am I missing some items?

Upvotes: 0

Views: 1345

Answers (1)

Bass Jobsen
Bass Jobsen

Reputation: 49054

use facebook->getLoginUrl with Permissions, see https://developers.facebook.com/docs/reference/login/#permissions

$applicationurl = 'http://{yourwebsite}/facebook.php';

// Get User ID
$user = $facebook->getUser();

if(empty($user))
{
   $params = array(
  'scope' => 'email',
  'redirect_uri' => $applicationurl
   );   

$loginUrl = $facebook->getLoginUrl($params);
header('Location: ' . $loginUrl ."\r\n");
exit;
} 

Use this code before your query. You can use $user in your query like uid = '.$user. Set your permissions in the scope part of your request, email in the example above.

EDIT OP says use the scope 'read_stream', and it works

Upvotes: 2

Related Questions