Eduardo Iglesias
Eduardo Iglesias

Reputation: 1049

facebook api return nothing but with me I have the data

I make a Facebook app, now we change it from server and I run again the codes to test it, and I found that it works perfectly except for one FQL. I get the user info with ->(/me)

The FLQ works (I tested with Facebook tools). My connection and scope its correct. any idea?

I leave you my fql

$scope = 'email,read_stream';
$facebook = new Facebook(array(
     'appId'  => $app_id,
     'secret' => $app_secret,
));

// Get the current user
$user = $facebook->getUser();
    $fql    =   "SELECT type, source_id, share_count, likes, permalink, description, post_id, message, target_id, created_time, attachment
                FROM stream 
                WHERE source_id =  me()  and type in (46, 80)
                order by created_time desc
                LIMIT 500";
    $param  =   array(
     'method'    => 'fql.query',
     'query'     => $fql,
     'callback'  => ''
    );

    $fqlResult  =  $facebook->api($param);
    print_r($fqlResult);

Upvotes: 0

Views: 251

Answers (3)

Eduardo Iglesias
Eduardo Iglesias

Reputation: 1049

I found my problem,

the code works, but I was asking for two specific types. and type in (46, 80)

When I remove it it appear all the stream :)

Thanks to everyone

Upvotes: 1

GroovyCarrot
GroovyCarrot

Reputation: 514

I wouldn't use FQL personally as there's a reason they depreciate the old API's, but to access feed data of the user you need to have granted access from the API for your application, it should handle access_tokens automatically but when your user logs in with your website you want to be using

$params = array(
  'scope' => 'read_stream, friends_likes',
   // Access to feed data (read_stream) and whatever else you need
  'redirect_uri' => 'https://www.myapp.com/post_login_page'
);

$loginUrl = $facebook->getLoginUrl($params);

Then you can access all the information you want with the api query:

$facebook->api('/me?fields=feed.fields(source,id,shares,likes,link,description,message,created_time)', 'GET');

I highly recommend using the Facebook Graph API Explorer to test API queries and retrieve all the information you need

Hope that helps mate!

Upvotes: 2

Sahil Mittal
Sahil Mittal

Reputation: 20753

In the parameter array, add one more parameter : access_token and give it the valid access token value

Upvotes: 1

Related Questions