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.
Related
This should be an easy one. All I want it the user's profile url.
I've tried the following FQL:
SELECT profile_url FROM standard_user_info WHERE uid = me()
but get the Request Failed error. I'm using the Graph API Explorer / FQL Query and have the latest Access Token.
Basically I'm looking for the FQL equivalent to this Graph API call:
https://graph.facebook.com/me?fields=link
Thanks for the help
If you read the documentation properly, you'll notice that-
standard_user_info requires the APP_ACCESS_TOKEN, instead of USER_ACCESS_TOKEN. You can get the App Access Token from the Access Token Tool, for the testing.
You can get the information about the authorized app users only.
So, you can test it like this-
SELECT profile_url FROM standard_user_info WHERE uid = USER_ID
Note: Don't use me() (since you are using the app access token now which didn't recognize me()), instead use you ID)
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.
According to the FQL Stream documentation the following query is supposed to return impression counts when run by an authenticated page owner, yet it never does. We have the page owner authenticating directly in the graph api explorer with extended permissions (read_stream, read_insights), but the impression counts are always null.
Is anyone able to get this working?
SELECT post_id, actor_id, message, impressions FROM stream WHERE actor_id = {owned_page} and source_id = {owned_page}
I think its missing in the documentation, but you should make this call using the page access token instead of user access token to get it worked.
So here are the steps:
Get the following permissions from the user and get the user access_token:
manage_pages - to get the page access token
read_insights - to read the impressions (as mentioned in the doc)
read_stream - for all posts that the current session user is able to view
Using that token, get the page access_token with the call-
/{page-id}?fields=access_token
(optional) Check out my answer here to extend this page access token that will never expire. (Basically to avoid some steps)
Using the page access token, run your query-
SELECT post_id, actor_id, message, impressions FROM stream WHERE actor_id = {owned_page} and source_id = {owned_page}
This will fetch you the impressions(if any) in the result.
Hope that helps.!
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.
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