Getting statuses and wall pictures through single Graph API call - facebook

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.

Related

Get recent photos from the Facebook v2.1+ graph api

Facebook's FQL was deprecated after v2.0. The website I'm working on previously had a "Recent photos" feature that populated recent photos using this FQL:
var fql = 'SELECT object_id, aid, images, album_object_id, created, modified, position, caption
FROM photo
WHERE aid in (SELECT aid, owner FROM album WHERE owner = me())
ORDER BY created DESC
LIMIT 59';
I'm trying to figure out a comparable way to do that using the graph api. the /photos endpoint is probably what I want, but I can't figure out if it has a valid order queryparam.
In postman I've been messing around with this:
https://graph.facebook.com/v2.2/10151316456544622/photos?fields=picture,name,source,created_time&limit=20&order=-created_time&debug=all&access_token=CAAL7TZAyo4RUBAOJe4Jgjdt6NZAqcajRghEGdKwraq4X1yZAKjvgXj4xXAZCoyZCkzMO84mTMJ90Vp5CEfJsT1WsoOwif2QZCS00bGqZAVxqmZChMUqKQmNsu2DvZCoY42ZC5fSBAxUuNCqTWg1QZCBZCz5oQx3wcNZCZCPUHOXMu5i5jZCOTGIiPWrAeTlzhFBqkvoZBZAPSJRhlkdxyrKPmpmOqgKrUeD13TdOtKU4ZD
The access_token is of a FB test account, feel free to go nuts. I'm not getting any debug information. There doesn't appear to be anything in the docs about how to change the order of photos.
This example url might not be the best. There's only 7ish public photos for this account, but I will potentially be getting recent photos from accounts with 1000s of photos. I don't want to just get all photos and reverse the list. I want to the most recent 20 photos in one call.
Any ideas? Is there order documentation that I've missed?
There is no direct way to achieve this using the Graph API, but you can use Real Time Updates to get notified about changes to the photos of a user.

Facebook Graph API - get postst posted by my aplication

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.

Get user's facebook posts on friends' wall

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?

Facebook API: Can I access my page's user's content?

I'm trying to develop a management tool for my pages and to do that, I need access to the content my users post (as I repost a lot of their content - ex. photos)
It looks like I can get access to all the content that I post, but I can't seem to find any reference to features that'll allow me access to the user's content.
Is this not available in the API?
You can get all the posts for a page at:
https://graph.facebook.com/[PAGE_NAME_OR_ID]/feed?access_token=...
However, you can't filter on this very well. An option that gives you more control is FQL. This query of the stream table should get you started with posts by others.
SELECT post_id, actor_id, message, attachment, permalink FROM stream
WHERE source_id = [PAGE_ID] AND filter_key = 'others'
If a user has set their post to private, it won't be returned by this call. You also need to be aware of the limits of the stream table: It only returns up to 50 posts in the last 30 days. If you want more, you have to use a LIMIT clause to page through your results.
I am developing Facebook application from last two years as per my experience you can't get any users information and using Page Signed request you can get userid,isowner,timezone and isLiked only..

How to convert Facebook REST API PID for a photo to its unique Graph ID?

I know both the old Facebook REST API and the new Graph API fairly well. Through the graph api and given maximum permissions I can request a user's photos (its my app and my account):
client.Get("/me/photos");
This returns an array of json encoded graph api photos. The only problem is that it's not the total number of photos in the account. I checked this by painstakingly counting my facebook photos AND comparing it against a simple call from the old REST API:
select pid from photo where aid in (select aid from album where owner=me())
(the above from memory, but what I had worked well)
My count and the REST API confirm that the graph API is NOT returning all the photos in the account (I know about paging as well).
Does anyone know why this is? Also, does anyone know how to convert an old REST API pid (photo id) to a new GRAPH API unique ID. It's the only way I can think of to get all the photos.
FQL is still available in the Graph API
https://graph.facebook.com/fql?q=select pid from photo where aid in (select aid from album where owner=me())
Also, there's another property called object_id on the photo fql table which should correspond (if memory serves) to the id in the photo api table
https://developers.facebook.com/docs/reference/fql/photo/
https://developers.facebook.com/docs/reference/api/photo/
Try:
https://www.facebook.com/photo.php?pid=11504724&l=3f088bdde4&id=99984862969
https://graph.facebook.com/fql?q=select object_id from photo where pid="99984862969_11504724"
Response should be:
{
"data": [
{
"object_id": "10151373634447970"
}
]
}