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.!
Related
I've been trying to query what people have posted on my wall as a quick metric of closeness. I've tried both FQL and the Graph API to make these queries without a problem...
FQL:
SELECT actor_id FROM stream WHERE source_id = me() AND message != "" LIMIT 50
Graph:
FB.api('/me/feed?fields=from&limit=50', function(feedresponse) { //do stuff });
Testing these in the Graph Explorer when the application is set to "Graph API Explorer" returns the values I want - my own and other's posts on my wall.
However when the application is changed to my own application, "Fingerprint", the values include my likes, my recent friendship notifications, etc... information I don't want returned and that completely pollutes the query.
I've still gotten the correct results by passing the Graph API Access Token like so:
var access_token = "CAACEdEose0cBALLruchzIKJ1ewgvcjpPJmo1amJwbMHGYyuk544om8hDILt0ZBXiUAriiNI7VY2g1OOwlEgV4bVyCWZACOf2djD1rYBTIwxBnmseNHUm6qybvus23F4AShctQl3wu0rpPS5ZBh68ypVoDMgyyXEGnu6uXBbzOJ7Tx43m2xHsseo1oiU7A80oelxphhidgZDZD";
FB.api('/me/feed?fields=from&limit=50', { access_token : access_token}, ...
Though it works - it definitely doesn't seem like the right way. Can anyone explain why the results are different and how I can get my feed without the other bullshit FB sends me when I'm using the User Access Token with my App.
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)
When I do a FQL query like the following (where <userId> is the Facebook ID of my FB friend):
SELECT type, post_id, created_time, updated_time, source_id, message, description, attachment FROM stream WHERE filter_key in (SELECT filter_key FROM stream_filter WHERE uid = <userId> AND type = 'newsfeed') AND is_hidden = 0 LIMIT 250
I'm getting the following error:
"error": {
"message": "(#606) uid in the where clause must be the session user",
"type": "OAuthException",
"code": 606
}
This seems wrong to me, because the examples in the stream_filter docs clearly use this example.
If the only way to get a stream_filter is by calling WHERE uid=me() then what is the point of the WHERE clause at all?
Is this a permissions issue with my access token?
If you are doing an FQL query based on the uid of your friend, you need to be authorized. Once authorized, you can add the access token granted by the user (in this case, your friend) to your query and have permission to get the results you're querying for.
This is because you're trying to fetch data, which in this case being their news feed comprised of posts created by their friends and pages they follow, that belongs to the user, which essentially belongs to them. You need to authorized to be able to access their data or act on their behalf to post photos and such.
However, if you're trying to get their own stream of posts that they themselves generate, you can totally get those, assuming that they are public and accessible by their set permissions. You can use a Graph API call:
https://graph.facebook.com/<userId>/feed?access_token=<your access token>
I'll also throw this in: You can read your own news feed as well with a Graph API call:
https://graph.facebook.com/me/home?access_token=<your access token>
You just need to make sure you have the 'read_stream' permission. If you try to get the news feed of another user by replacing 'me' with the user id, you'll get an error from Facebook:
{
"error": {
"message": "You can only access the \"home\" connection for the current user.",
"type": "GraphMethodException",
"code": 100
}
}
This further confirms that you can't access another user's news feed unless you have their permission, ie. being granted an access token that belongs to them.
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.
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.