I am trying to get all the photos that my app has posted to a user's str开发者_高级运维eam using FQL. I realize I could do this by first performing the following query:
SELECT attachment FROM stream WHERE source_id = me() AND app_id = <my_app_id>
and then parsing the attachments locally to determine their type. But I'm wondering, is there any way to include the attachment type in my query so that only attachments with photos are returned?
Facebook has updated the stream table to include "type":
https://developers.facebook.com/docs/reference/fql/stream/
The type of this story. Possible values are:
11 - Group created
12 - Event created
46 - Status update
56 - Post on wall from another user
66 - Note created
80 - Link posted
128 - Video posted
247 - Photos posted
237 - App story
272 - App story
So the answer to my question becomes:
SELECT attachment FROM stream WHERE source_id = me() AND type = 247 AND app_id = <my_app_id>
By the way, it doesn't seem they retroactively updated the stream table i.e. old posts do not have a "type" value
if you have not selected/created a specific album for photos being posted to a users account, all of them will be in the same album - something like <app_name> Photos
.
Taken from facebook blog post 489 :
...We automatically create an album for your app if it does not already exist. All photos uploaded this way will then be added to this same album.
From there you could retrieve all photo posts made by your app. I find it very unlikely that a user would upload a photo into your app's specific album (although its possible)
In addition, saving photo_id/album_id in your own database for use in the future is a great idea.
精彩评论