Sisir
Sisir

Reputation: 2816

How to fetch facebook users profile stream with php?

I am trying to get users profile stream via facebook api. I have read all related post that pop up is stackoverflow but did not found the answer. I am using simple fql for this.

SELECT actor_id, message FROM stream WHERE source_id = <user id> limit 50

This fql statement is from facebook developer site So it should work but its not. Note that i am not using facebook connect. But according to the site i should still able to get the public posts, right?

here is the code i am using:

    $fql = 'SELECT actor_id, message FROM stream WHERE source_id = <user_id> limit 10';
    $query = 'https://api.facebook.com/method/fql.query?query='.urlencode($fql);
    $status = file_get_contents($query);
    echo $status;

The error i am getting is failed to open stream in php and when i write the url in browser directly i am getting this error 104 Requires valid signature method fql.query query SELECT message FROM stream WHERE source_id =<user_id> limit 10

Also i need to know what command to use in FQL if i want JSON data format.

Upvotes: 1

Views: 955

Answers (1)

jers
jers

Reputation: 26

Facebook has recently updated the API so that it now requires an access_token to query the stream table using FQL. So your query won't work without an access_token.
See this blog post for more information.

To get a JSON response, add "?format=JSON" after your query.

Upvotes: 1

Related Questions