How to get "newly added photos to an album" in facebook news feed using Graph Api

S.P. picture S.P. · Jun 29, 2011 · Viewed 7.9k times · Source

I am getting facebook news feed using

News feed: https://graph.facebook.com/me/home?access_token=MyAccessToken

I am getting all news feed object.But in news feeds object with type "photo",

I am getting only last added picture url (If user is added some photos to that album).

But how to get news feeds like "Jack added 3 new photos to the album MyApp Photos."

I want to get 3 photos in that album , if user added any photos to an album. I googled a lot.

Please help me. Thanks in advance.

Answer

BeRecursive picture BeRecursive · Jun 29, 2011

Alright - this is a little bit hacky but I can't see any otherway. In your news feed you will see an item along the lines of:

{
         "id": "123456789_3453453455345334",
         "from": {
            "name": "A Friend",
            "id": "123456789"
         },
         "to": {
            "data": [
               {
                  "name": "A Friend",
                  "id": "123456789"
               }
            ]
         },
         "picture": "PICTURE_URL",
         "link": "http://www.facebook.com/photo.php?fbid=3453453455345334&set=a.10151233554845639.123456.123456789&type=1",
         "name": "Mobile Uploads",
         "caption": "10 new photos",
         "icon": "ICON_URL",
         "type": "photo",
         "object_id": "3453453455345334",
         "application": {
            "name": "Facebook for iPhone",
            "id": "6628568379"
         },
         "created_time": "2000-06-29T19:56:50+0000",
         "updated_time": "2001-06-29T19:56:50+0000"
      },

The key in there is the link url, which contains:

set=a.10151233554845639.123456.123456789

The first number, after the a, appears to be the album id. We can therefore get the photos from the album by querying:

https://graph.facebook.com/10151233554845345/photos?access_token=ACCESS_TOKEN

If you share a photo that already exists on Facebook then it appears with an extra property called properties:

"properties": [
            {
               "name": "By",
               "text": "A Friend",
               "href": "http://www.facebook.com/a.friend"
            }
         ],

If you share a photo on your wall this is actually an upload and so will not include the properties property