FQL query error 104 - facebook-fql

last week I needed to run a FQL query to return the last wall post of a public page, which is very basic
SELECT actor_id, message FROM stream WHERE source_id = 122338662806 limit 1
it worked fine, returned an xml schema and I then went to get the message from there. This is all done in the backend of a website, and not a facebook application.
Sunday night though, it stopped returning anything and started giving me:
<error_code>104</error_code>
<error_msg>Requires valid signature</error_msg>
which after some research, means it wants an access_token. Since this is not a facebook app, is there a way around this, since it's a public page?
Thank you in advance!

I don't know the way its done for public pages but adding an access_token worked for me
SELECT actor_id, message FROM stream WHERE source_id = 122338662806 limit 1&access_token=YOUR_ACCESS_TOKEN
this is what facebook says,
GET /fql?q=SELECT+uid2+FROM+friend+WHERE+uid1=me()&access_token=YOUR_ACCESS_TOKEN

Related

How can I get all my posts to other people, not to my timeline?

How can i get, using Facebook Graph Api, all my posts to other people, not to my timeline?
I'm trying to use me/posts , but i get all my posts including to my timeline, and i couldn't separate it
Using Facebook FQL API:
SELECT post_id, created_time, description, description_tags, app_id,
message, type, created_time FROM stream WHERE source_id=me() AND
comment_info.can_comment!='' AND actor_id=me() AND permalink="" AND
created_time<=now() LIMIT 150
The only problem is this query doesn't return "Upload photo on friends wall"'s post, because of this unresolved bug at https://developers.facebook.com/bugs/148353975327544. However, this FQL query should works perfectly. Kindly let me know if you're figure out something wrong with this query.
Also, please make sure your user access token have granted "read_stream" permission.
comment_info.can_comment!='' used to exclude "Comment on friend's Status" story feed.
permalink="" used to exclude "Lim and 林果皞 are now friends." or "People changed his profile picture.", "林果皞 created an event."...etc. You can test what would happen if remove this.
Update for comment below:
I think what you can do is extract the id from description_tags which was no start with "0", for example my screenshot, id "100003013144869":
Also, extract the created_time, for example "1368624514"
Then, do a query with:
SELECT post_id FROM stream WHERE source_id='100003013144869' AND
actor_id=me() AND created_time=1368624514
I'm know it's not absolutely accurate(If 2 feed have the same created_time on seconds), however most likely you can make your job done.

Unable to retrieve events created by a page

I have tried with EVERYTHING, graph, FQL, access_token with all permissions granted, multi-queries... now I'm really tired! Someone can tell me HOW to retrieve all the events created by a page like this? http://facebook.com/mammamiasantateresa
I want to know why this query doesn't work:
SELECT eid, name, description, location, pic_big, start_time, end_time, is_date_only FROM event WHERE creator = 229315807171062
But instead, this query with this page: 205712556144006 (/fifteenonline) who has only an event, or with Coldplay's page 15253175252 (/coldplay), who has many events, it just works!!! I wonder why. Nobody for weeks gave me a response. Please, it's very important for me. Thanks!
Your query is OK and if this would be an event it should be worked. But the thing you're looking for is a post on a wall, not an event, and it could be found via searching in stream in Graph API or FQL query:
Graph API request:
http://developers.facebook.com/tools/explorer?method=GET&path=229315807171062%2Ffeed
FQL Query request (with 2 fields, but anyway this post is there):
http://developers.facebook.com/tools/explorer?fql=SELECT%20message%2C%20updated_time%20FROM%20stream%20WHERE%20source_id%20%3D%20229315807171062

realtime api feed - how to get new comments?

I made it to subscribe to the realtime api and retrieve update messages telling me the uid and time when the item changed. But how do I get the corresponding post/comment. I tried to use the fql but unfortunately there seems to be a bug in the fql when using updated_time.
This is my query:
SELECT post_id, actor_id, target_id, updated_time, message FROM stream WHERE source_id = me() AND updated_time >= "pushTime"
where pushtime is the time I got from the realtime notification.
It works for getting a standalone(no comments) post but as soon as there are comments it does not work. When I go through all posts and check the updated_time I can find the correct post.
My only solution for the time being is to iterate over all posts until i find the post where updated_time == "pushTime".
Anyone another solution?
If you have stored previous comments then retrieve the last comment ID you have stored and use that to query facebook for comments with an ID higher than that.

FQL/Graph API retrieves all post from the wall of a Page except one

i have the problem that querying posts from the wall of a page returns all posts except one post. I can't explain why this post isn't retrieved.
I hope someone could help me why FQL/Graph API is failing.
https://www.facebook.com/pages/WILIKE-INWI-Uni-Graz/295421080475868
The conecerning post is that one from "Doris Rath".
This is the query i use (which works fine except for this specific post).
$streamQuery = 'SELECT post_id, message, permalink, likes, actor_id, created_time FROM stream WHERE source_id';
$streamQuery .= '= 295421080475868 AND message != "" LIMIT 1000 OFFSET 0';
There's still no explanation why the request does not work ... :(
Still no solution! Have a new ID of a post which returns false: 286722628036968
I think that this post contains the answer to your question Facebook Graph API returns 'false' even though post is public
The post is not truly public, as when I logged out, the post from Doris Rath was not visible.
The only way to get through this post, would be through a logged in and authorised user with manage_pages permission.
It is because the user who had posted the message has turned off the app in his profile
setting of app
Check the image.

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.
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.