我想知道当用户上传新照片(无论是在他的相册中、作为状态更新还是群组中)时,我需要订阅哪些对象和连接才能接收通知(facebook 实时更新功能)。
这与用户个人资料图片无关,而是用户在 Facebook 上分享的任何照片。
我想知道当用户上传新照片(无论是在他的相册中、作为状态更新还是群组中)时,我需要订阅哪些对象和连接才能接收通知(facebook 实时更新功能)。
这与用户个人资料图片无关,而是用户在 Facebook 上分享的任何照片。
Facebook says the following at the Realtime Updates description (https://developers.facebook.com/docs/reference/api/realtime/ - Below "Types of Updates"):
Note that you can not subscribe to changes on all properties and connections of the User object. Connections to which you can subscribe include: feed, friends, activities, interests, music, books, movies, television, likes, checkins, location, events.
The only thing I could think of is that you subscribe to the feed connection and do some postprocessing to find out whether the post was related to a photo:
GET https://graph.facebook.com/{USER_ID}/feed?fields=id,link,type,link&since={YOUR_TIMESTAMP}&access_token={ACCESS_TOKEN}
You can derive the USER_ID from the POST coming from Facebook's Realtime Updates, the YOUR_TIMESTAMP can be something like the system time the POST was received minus 30 seconds, and the ACCESS_TOKEN needs to come from where you stored it once the User gave permissions to your app.
Then you can parse the resulting JSON for all array entries with "type": "photo" and you'll receive the posts who reference a photo.
You could then create a comma-separated list of the post_ids and use this in conjunction with a FQL query to get more details about the attached photos:
GET https://graph.facebook.com/fql?q=select+post_id,+attachment,+created_time+from+stream+where+source_id+=+{USER_ID}+and+type+=+247+and+post_id+in+({POST_ID_LIST})&access_token={ACCESS_TOKEN}
Within the resulting JSON, you can find the AID and the PID of the photos, which you can use to get more info about the photos. Or you use the URLs you'll find in images.src
You can get all photo posts via FQL in the following way, but this is then not related to the Realtime Updates:
select post_id, attachment, created_time from stream where source_id = me() and type = 247 limit 100