I am currently making a Facebook canvas app using Django and Python for Facebook. To be able to make my app I need to retrieve the posts the user have made to his friends' walls. This has proven to be a challenge.
I have tried using the connection user.posts with the graph API like this:
graph = facebook.GraphAPI(access_token)
posts = graph.get_connections('me', 'posts' , limit=5000)
Which in the graph explorer would be something like:
graph.facebook.com/me/posts
The post objects from this request does however not return any posts from the user on his friend's walls.
I also tried an FQL query which didn't return anything, at least not with myself as the user:
SELECT actor_id, message, post_id, source_id, tagged_ids, type
FROM stream WHERE type=56 AND source_id IN (SELECT user_1 FROM friend WHERE user_2=me())
I'm pretty sure that I could get what I wanted if I did a request for each friend separately but that would be too time consuming to be efficiently implemented. Does anyone have any ideas on how to do this in one or two calls?
Related
I'm trying to get the 50 x 50 profile picture for user posts on the news feed. It's easy to do this for likes and comments on posts but I can't figure out how to do it for the initial posts.I also want to limit the query so that I only get results from "people" not "pages" and I only want unique results. In other words if a user appears twice on the feed I only need their picture once. I've played with the Graph API Explorer extensively and have looked all over the forums, here, as well as the documentation on the Facebook developers site. I would think this would be a common request so I'm not sure why it's been so hard to find.My guess is that the syntax of the query would look something like this. Although this query doesn't work in the explorer.
me/home/?fields=from.id.fields(pic_square),from&profile_type=user
Well after a lot of research and trial and error with FQL I figured it out. It's a series of nested queries and it returns an array with the urls of the pic-square images of the users whose posts appear in your news feed. The FQL query looks like this:
SELECT pic_square FROM user WHERE uid IN (SELECT actor_id FROM stream WHERE filter_key IN (SELECT filter_key FROM stream_filter WHERE uid=me()))
I was not able to differentiate between user and page profile pics.
How to compose request which is retrieve wall posts posted by my application or at least I want to get ALL posts posted by any application or user. Now I can see only posts from myself and friends : me?fields=feed with permission read_stream. If it impossible withGraph API how to do this with FQL ?
select message from stream where source_id = DESTINATION ID and app_id= YOUR APP ID
If you want to filter by stuff your app is posting you have to find the id that your app is posting on. This is the "soure_id" ie where your post is going. Then you just have to add the parameter of what your app_id is that your app is posting as. If you wanted to filter by user you would just insert their uid as the actor_id instead of app_id.
I'm accessing the Facebook API through the JavaScript API and need the users statuses and wall photos. I'm getting the statuses through /me/statuses, but I do not really have a clue how to include the picture statuses instead of merging the data with the pictures that can be found in the album "Wall Photos". It would be great if that would work with a single request to enable proper pagination.
You have to set up an app and get the read_stream permission from the user if you haven't already.
Then you can use me/feed to query all posts on the wall.
The type of the post won't show up as status but as photo, no matter if it has been uploaded to an album and then shared or directly shared via status update. That is probably why you can't get them through me/statuses.
You can use FQL to get that info – the stream table has a field called type, and you can “filter” that for certain types by using the IN operator:
SELECT post_id, message, attachment, type FROM stream WHERE source_id = me()
AND type IN (46, 247)
46 is a status update, 247 is a photo posted to the wall.
I am developing an IPhone app. The user can post to his wall and now I want to read ONLY the news feeds that was posted from the IPHone app.
When I use
https://graph.facebook.com/me/feed?access_token=...
I get all wall posts, and I can recognize the one posted from the iphone app by the "application" node in the JSON response. How can I filter those feeds? Should I use FQL instead?
Thanks!!!
Edit: I tried using https://graph.facebook.com/search?q={My application name}&type=post&access_token= with no success...
Yep, FQL is the way forward, you can pass an app_id: http://developers.facebook.com/docs/reference/fql/stream/
So your query could be like: SELECT post_id, actor_id, target_id, message FROM stream WHERE source_id = me() AND app_id = 'my_app_id'
The Facebook Graph API lets you grab a JSON representation of home (News Feed) & feed (Wall).
How do I just get the posts made by my Facebook app?
Facebook has added support to filter me/home posts without using FQL by passing the filter parameter.
For example to get just photos you can do:
me/home?filter=app_2305272732
Full documentation is here: http://developers.facebook.com/docs/reference/api/user/#home
You can now run Facebook Query Language (FQL) queries using the Facebook Graph API (base URL: https://graph.facebook.com).
Let's say your application is Twitter. Twitter's Facebook application ID is 2231777543.
I came up with the FQL queries below with the help of #danontheline's answer and by carefully reading Facebook's documentation on FQL stream & FQL stream_filter.
The following excerpt is particularly pertinent:
If you specify a filter_key from the stream_filter FQL table or
multiple users, results returned will behave like the user's homepage
news feed. If only one user is specified as the source_id, you will
receive the profile view of the user or page. You can filter these
profile view posts by specifying filter_key 'others' (return only
posts that are by someone other than the specified user) or 'owner'
(return only posts made by the specified user). The profile view,
unlike the homepage view, returns older data from our databases. In
the case of a Page, the profile view also includes posts by fans.
Twitter Tweets on Your Facebook News Feed
GET /fql?q=SELECT post_id, actor_id, message, app_id, attribution FROM stream WHERE filter_key = 'app_2231777543'
Twitter Tweets on Your Facebook Wall
GET /fql?q=SELECT post_id, actor_id, message, app_id, attribution FROM stream WHERE source_id = me() AND app_id = '2231777543' LIMIT 1000
Running these queries with the Facebook Graph API Explorer returns Facebook Graph API post objects (The result set will differ depending on access_token, privacy, etc.). You can find out more about each post by adding other columns of the stream table to the queries above and/or by simply making another Graph API request to GET /{post_id} for eache post_id returned by the FQL stream queries above.
Afaik thats not possible with just the Graph API. But you can just use a FQL statement to retrieve the wall/feed, too. With this technique you are able to resrict it to the posts made by one actor_id (which should be your app ID in this case):
SELECT post_id, target_id, message FROM stream WHERE filter_key in (SELECT filter_key FROM stream_filter WHERE uid=me() AND type='newsfeed') AND is_hidden = 0 AND actor_id = 'MattDiPasqualesAppID'
Thing here is that it won't return a JSON, but a XML representation of the result. With phps DOM class you are easily able to convert it into a JSON format or any other representation you want to have of the result!
As you might be handling the whole thing with PHP anyway, you also could just take the json array, parse it into an array and filter the array with keys of your appID.