facebook graph - retrieve multiple photos - facebook

I want to retrieve all photos that can be posted in a single Facebook post.
For example, in this post, there are two photos.
Using the Graph API (https://graph.facebook.com/v2.6/AtifAslamOfficialFanPage/posts?fields=id,type,created_time,link,message,source,object_id&limit=10&access_token=xxx) I get for this post:
{
"id": "182973122142_10153437154822143",
"type": "photo",
"created_time": "2016-03-18T17:47:23+0000",
"link": "https://www.facebook.com/AtifAslamOfficialFanPage/photos/a.281303247142.151444.182973122142/10153437154412143/?type=3",
"object_id": "10153437154412143"
}
but there is only one object_id, which is the first photo of the post.
Is it possible to retrieve all photos?

Request the attachments field, 182973122142_10153437154822143?fields=attachments, and you will get the following data structure:
{
"attachments": {
"data": [
{
"subattachments": {
"data": [
{
"media": {
"image": {
"height": 266,
"src": "https://scontent.xx.fbcdn.net/v/t1.0-9/s720x720/10314482_10153437154412143_7582591571482186627_n.png?oh=a2b350ce8ac6ae546022295c7e73245a&oe=579E6E12",
"width": 720
}
},
"target": {
"id": "10153437154412143",
"url": "https://www.facebook.com/AtifAslamOfficialFanPage/photos/a.281303247142.151444.182973122142/10153437154412143/?type=3"
},
"type": "photo",
"url": "https://www.facebook.com/AtifAslamOfficialFanPage/photos/a.281303247142.151444.182973122142/10153437154412143/?type=3"
},
{
"media": {
"image": {
"height": 720,
"src": "https://scontent.xx.fbcdn.net/v/t1.0-9/p720x720/10314505_10153437154507143_8615151666809542144_n.jpg?oh=4255fb5699cf0a4d5c455be82cbb8efe&oe=57E38281",
"width": 720
}
},
"target": {
"id": "10153437154507143",
"url": "https://www.facebook.com/AtifAslamOfficialFanPage/photos/a.281303247142.151444.182973122142/10153437154507143/?type=3"
},
"type": "photo",
"url": "https://www.facebook.com/AtifAslamOfficialFanPage/photos/a.281303247142.151444.182973122142/10153437154507143/?type=3"
}
]
},
"target": {
"id": "10153437154822143",
"url": "https://www.facebook.com/AtifAslamOfficialFanPage/posts/10153437154822143"
},
"title": "Photos from Atif Aslam's post",
"type": "album",
"url": "https://www.facebook.com/AtifAslamOfficialFanPage/posts/10153437154822143"
}
]
},
"id": "182973122142_10153437154822143"
}

Related

Facebook graph API v12 users photos and likes

Back years ago I used the Facebook Graph API to gather users friend photos and likes for those photos. However, that was back when the API was v2.11 or v4 or something like that. Now at version 12, my code no longer works. I've tried getting the same data I once did back using their Graph API but I have no success in doing so.
I have the JSON below to show what data I used to get and which I am now trying to get again. Note that no links within the JSON will work - this is only an example.
Basically Its gathering my friends photos by their ID in ascending order and anyone who has liked those photo.
The call I would normally make to get this data was:
https://graph.facebook.com/[user id]/picture?type=large&width=720&height=720
Are you still able to get other friends photos as well or has that been stopped now? Do your friends have to join your Facebook app in order to gather photo data like this from them?
{
"data": [{
"created_time": "2017-12-08T18:57:53+0000",
"likes": {
"data": [{
"name": "Bill Gates",
"id": "9485030985688759"
}, {
"name": "Bob Barker",
"id": "1944578789965397"
}, {
"name": "Steve Jobs",
"id": "4423564564766486"
}, {
"name": "James Bond",
"id": "1027785445557557"
}, {
"name": "Bart Simpson",
"id": "10214564574448423"
}, {
"name": "Lisa Simpson",
"id": "16845876543328680"
}
],
"paging": {
"cursors": {
"before": "MTAyMHISTeY5MjYyOTE2NzQZD",
"after": "MTUzODUYTREEewQ5OTA2MwZDZD"
}
}
},
"images": [{
"height": 960,
"source": "https:\/\/scontent.xx.fbcdn.net\/v\/t1.0-9\/243633743_10101633995322638_8617605831554312755_n.jpg?oh=d4ca434j6nrn4332d723981a8b3e7137e4&oe=5B044D79",
"width": 720
}, {
"height": 800,
"source": "https:\/\/scontent.xx.fbcdn.net\/v\/t1.0-0\/p600x600\/24909743_10345633995322638_8614363524112755_n.jpg?oh=60e21c107fe171898452tre338a4c918&oe=5B479FB6",
"width": 600
}, {
"height": 640,
"source": "https:\/\/scontent.xx.fbcdn.net\/v\/t1.0-0\/p480x480\/24909743_1013473995322638_861760343422414112755_n.jpg?oh=5302f74db20c780436nGddn16461f70&oe=5Bttr48C",
"width": 480
}
],
"id": "10101633993437538"
}, {
"created_time": "2017-06-05T21:14:28+0000",
"likes": {
"data": [{
"name": "Amy Someone",
"id": "453437546783720"
}, {
"name": "Mike LG",
"id": "181855436553221"
}, {
"name": "Homer Simpson",
"id": "194335643226397"
}, {
"name": "Bart Simpson",
"id": "194332353226397"
}
],
"paging": {
"cursors": {
"before": "MTAyMTMRFeht5zg3MzM3MjAZD",
"after": "MTUzODcfrhreOTQ5OTA2MwZDZD"
}
}
},
"images": [{
"height": 1440,
"source": "https:\/\/scontent.xx.fbcdn.net\/v\/t31.0-8\/18839799_10101467545354528_4346343h5628628521_o.jpg?oh=31297frt35y6e892c0807dad0345b58eb&oe=5B157345",
"width": 800
}, {
"height": 1296,
"source": "https:\/\/scontent.xx.fbcdn.net\/v\/t31.0-8\/p720x720\/18839799_10101417914904528_4346353536428628521_o.jpg?oh=809bb29a5b55e222411a014c8392eea2&oe=5B47D7B8",
"width": 720
}
],
"id": "10134664346528"
}
]
}
As a test I sent my wife a request to be a tester and she approved it but I still can not even pull data from her account?
As you see it just has my friend count and nothing more.
I also made sure it accepted my wife as a tester and it looks like it has:
But that does have a debug message saying:

Facebook real time updates giving incomplete information on page events

I have subscribed for page subscription for Facebook real time updates with Fields as "feed". When i am creating a new event, the Facebook real time updates sends me a wrong entry. The entry i got as a real time update is below.
{
"entry": [
{
"changes": [
{
"field": "feed",
"value": {
"photo_id": 1128416807216170,
"**post_id": "902483569809496_1128416807216170"**,
"sender_name": "Unofficial: Aerospace Demodavid",
"sender_id": 902483569809496,
"item": "photo",
"verb": "edited",
"link": "https://scontent.ford1-1.fna.fbcdn.net/t31.0-8/13717445_1128416807216170_1696828468485436508_o.jpg",
"published": 1,
"created_time": 1470269376
}
}
],
"id": "902483569809496",
"time": 1470269377
}
],
"object": "page"
}
From the above entry, if i query the Graph API for postid : 902483569809496_1128416807216170 , i get the below JSON response
{
"created_time": "2016-08-04T00:09:36+0000",
"actions": [
{
"name": "Like",
"link": "https://www.facebook.com/902483569809496/photos/gm.713007008848308/1128416807216170/?type=3"
},
{
"name": "Comment",
"link": "https://www.facebook.com/902483569809496/photos/gm.713007008848308/1128416807216170/?type=3"
},
{
"name": "See Friendship",
"link": "https://m.facebook.com/friendship/902483569809496/713006992181643/"
}
],
"from": {
"name": "Unofficial: Aerospace Demodavid",
"category": "Aerospace/Defense",
"id": "902483569809496"
},
"icon": "https://www.facebook.com/images/icons/photo.gif",
"is_hidden": false,
"is_expired": false,
"link": "https://www.facebook.com/902483569809496/photos/gm.713007008848308/1128416807216170/?type=3",
"object_id": "1128416807216170",
"picture": "https://scontent.xx.fbcdn.net/v/t1.0-0/s130x130/13892116_1128416807216170_1696828468485436508_n.jpg?oh=967e908192fcadc72eae9c11047f87e2&oe=582D6009",
"privacy": {
"allow": "",
"deny": "",
"description": "",
"friends": "",
"value": "EVERYONE"
},
"status_type": "added_photos",
"subscribed": false,
"to": {
"data": [
{
"id": "713006992181643",
"name": "Stevie G Event"
}
]
},
"type": "photo",
"updated_time": "2016-08-04T00:09:36+0000",
"id": "902483569809496_1128416807216170"
}
But the actual thing added here was an event and not a photo. The id should be 902483569809496_713006992181643 as in the below JSON and not 902483569809496_1128416807216170 which came from the real time update. Below is the JSON response which i am getting when i query the Graph API manually using the account id without using the real time update information.
{
"id": "902483569809496_713006992181643",
"from": {
"name": "Unofficial: Aerospace Demodavid",
"category": "Aerospace/Defense",
"id": "902483569809496"
},
"story": "Unofficial: Aerospace Demodavid added an event.",
"story_tags": {
"0": [
{
"id": "902483569809496",
"name": "Unofficial: Aerospace Demodavid",
"type": "page",
"offset": 0,
"length": 31
}
],
"41": [
{
"id": "713006992181643",
"name": "Stevie G Event",
"type": "event",
"offset": 41,
"length": 5
}
]
},
"picture": "https://scontent.xx.fbcdn.net/v/t1.0-0/c39.0.130.130/p130x130/13892116_1128416807216170_1696828468485436508_n.jpg?oh=5adc792bca82e0b110b3d6d98b81feae&oe=581E2680",
"link": "https://www.facebook.com/events/713006992181643/",
"name": "Stevie G Event",
"caption": "Stevie G Event",
"description": "Stevie G is the best",
"icon": "https://www.facebook.com/images/icons/event.gif",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/902483569809496/posts/713006992181643"
},
{
"name": "Like",
"link": "https://www.facebook.com/902483569809496/posts/713006992181643"
}
],
"privacy": {
"value": "EVERYONE",
"description": "",
"friends": "",
"allow": "",
"deny": ""
},
"type": "event",
"status_type": "created_event",
"object_id": "713006992181643",
"created_time": "2016-08-04T00:09:35+0000",
"updated_time": "2016-08-04T00:09:35+0000",
"is_hidden": false,
"is_expired": false
}
Why is there an inconsistency with the Facebook real time updates sent for an event creation. It treats it as a photo edit and not an event creation.
Please let me know if i am missing something.

How to get all the images posted in a single story on Facebook through graph api?

I am trying to get all the pictures and their engagements(comments or likes) that are posted together as a single page story. When I send a get request with the node being the page id and with parameter "field" the response that is get is:-
{
"id": "some_id",
"from": {
"category": "Tv show",
"name": "some_name",
"id": "some_id"
},
"message": "post with three photos",
"picture": "some_url",
"link": "some_link",
"icon": "some_link",
"actions": [
{
"name": "Comment",
"link": "some_link"
},
{
"name": "Like",
"link": "some_link"
}
],
"privacy": {
"value": ""
},
"type": "photo",
"status_type": "mobile_status_update",
"object_id": "some_object_id",
"created_time": "2014-02-04T15:12:37+0000",
"updated_time": "2014-02-04T15:54:12+0000",
"comments": {
"data": [
{
"id": "some_id",
"from": {
"category": "Tv show",
"name": "some_name",
"id": "some__id"
},
"message": "commen ton photo story",
"can_remove": false,
"created_time": "2014-02-04T15:54:12+0000",
"like_count": 0,
"user_likes": false
}
],
"paging": {
"cursors": {
"after": "MQ==",
"before": "MQ=="
}
}
}
},
In this post, I posted 3 photos together. But there is no information given to me from which I can get all the three photos through graph api calls. The object_id given to me is of the cover photo of the 3 images and is of a single image.
When I send a get request to the object_id, the response that I get is:-
{
"id": "some_id",
"created_time": "2014-02-04T15:12:38+0000",
"from": {
"category": "Tv show",
"name": "some_name",
"id": "some_id"
},
"height": 240,
"icon": "some_link",
"images": [
{
"height": 240,
"source": "some_link",
"width": 240
},
{
"height": 130,
"source": "some_link",
"width": 130
},
{
"height": 225,
"source": "some_link",
"width": 225
}
],
"link": "some_link",
"picture": "some_link",
"source": "some_link",
"updated_time": "2014-02-04T15:12:38+0000",
"width": 240
}
The link that is received is the url of the same image not of the 3 images.

How can I get all photos in one post using Graph API?

{
"id": "11882030_4952296803730",
"from": {
"name": "xxx",
"id": "11882030"
},
"message": "test",
"picture": "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/408410_4952294483672_298434229_s.jpg",
"link": "https://www.facebook.com/photo.php?fbid=4952294483672&set=pcb.4952296803730&type=1&relevant_count=2",
"icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yx/r/og8V99JVf8G.gif",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/11882030/posts/4952296803730"
},
{
"name": "Like",
"link": "https://www.facebook.com/11882030/posts/4952296803730"
}
],
"privacy": {
"description": "Friends",
"value": "ALL_FRIENDS",
"friends": "",
"networks": "",
"allow": "",
"deny": ""
},
"place": {
"id": "471607792876974",
"name": "TTT",
"location": {
"street": "",
"zip": "",
"latitude": x,
"longitude": x
}
},
"type": "photo",
"status_type": "mobile_status_update",
"object_id": "4952294483672",
"application": {
"name": "Facebook for iPhone",
"namespace": "fbiphone",
"id": "6628568379"
},
"created_time": "2013-01-17T01:29:59+0000",
"updated_time": "2013-01-17T01:29:59+0000",
"comments": {
"count": 0
}
}
As above, I posted a status with two photos. I can get the first photo's thumb URL in picture and the relevant link & count information in link.
But how can I get each photo's specific URL?
FQL often provides more information than Graph API. You have to use the attachment parameter of the stream FQL table to get all the attached photos.
SELECT attachment FROM stream
WHERE source_id = me()
AND post_id="11882030_4952296803730"
Result:
{
"data": [
{
"attachment": {
"media": [
{
"href": "https://www.facebook.com/photo.php?fbid=471082296...",
"alt": "",
"type": "photo",
"src": "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash3/5826...",
"photo": {
"aid": "4391039135",
"pid": "439104482145",
"fbid": 471507,
"owner": 102832,
"index": 1,
"width": 485,
"height": 172,
"images": [
{
"src": "https://fbcdn-photos-a.akamaihd.net/hph...",
"width": 130,
"height": 46
}
]
}
}
],
"name": "",
"caption": "",
"description": "",
"properties": [
],
"icon": "https://fbstatic-a.akamaihd.net/rsrc.phpjk.gif",
"fb_object_type": "album",
"fb_object_id": "4391044992857139135"
},
{
... //Photo 2
}
}
]
}
Based on Stéphane Bruckerts answer; you're after attachments. So I'd recommend simply requesting the attachments field in your graph request.
Although this question is a few years old, it still comes up when searching for this topic.
Facebook (Meta) Graph API has changed. Current Facebook (Meta) Graph API is version 13.0.
The best endpoint I found was to use the "/feed" URI slug, with "fields=attachments". Simply cURL / GET:
https://graph.facebook.com/v13.0/$PAGEID/feed?access_token=$AUTHTOKEN&fields=attachments,full_picture,id,message,story
Reference: https://developers.facebook.com/docs/graph-api/reference/v13.0/page/feed

PHOTO import from facebook wall

I am working on this site and I want to import photos from facebook group.
https://www.facebook.com/EveryoneLovesaGoldenRetriever/photos
If you visit this link above you will be able to see three albums under heading "Everyone loves a Golden Retriever's Albums" and many photos under heading "Photos of Everyone loves a Golden Retriever" i am able to fetch photos under the albums but not able to sort out how can i fetch other photos that doesnt belong to any albums and comes under heading "Photos of Everyone loves a Golden Retriever"
Thanks you very much in advance
SP
https://graph.facebook.com/115641638572281/tagged
{
"data": [
{
"id": "115641638572281_446639348697240",
"from": {
"name": "Sudhir Puranik",
"id": "100000535372598"
},
"to": {
"data": [
{
"name": "Everyone loves a Golden Retriever",
"category": "Small business",
"id": "115641638572281"
}
]
},
"picture": "http://a2.sphotos.ak.fbcdn.net/hphotos-ak-ash3/s320x320/541201_446639348697240_100000535372598_1627958_1814759730_n.jpg",
"link": "http://www.facebook.com/photo.php?fbid=446639348697240&set=o.115641638572281&type=1",
"icon": "http://static.ak.fbcdn.net/rsrc.php/v2/yz/r/StEh3RhPvjk.gif",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/115641638572281/posts/446639348697240"
},
{
"name": "Like",
"link": "http://www.facebook.com/115641638572281/posts/446639348697240"
}
],
"type": "photo",
"object_id": "446639348697240",
"application": {
"name": "Photos",
"id": "2305272732"
},
"created_time": "2012-05-15T07:43:58+0000",
"updated_time": "2012-05-15T07:43:58+0000",
"comments": {
"count": 0
}
},
{
"id": "115641638572281_446033935424448",
"from": {
"name": "Sudhir Puranik",
"id": "100000535372598"
},
"to": {
"data": [
{
"name": "Everyone loves a Golden Retriever",
"category": "Small business",
"id": "115641638572281"
}
]
},
"picture": "http://a5.sphotos.ak.fbcdn.net/hphotos-ak-ash3/s320x320/547601_446033935424448_100000535372598_1626229_2008301193_n.jpg",
"link": "http://www.facebook.com/photo.php?fbid=446033935424448&set=o.115641638572281&type=1",
"icon": "http://static.ak.fbcdn.net/rsrc.php/v2/yz/r/StEh3RhPvjk.gif",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/115641638572281/posts/446033935424448"
},
{
"name": "Like",
"link": "http://www.facebook.com/115641638572281/posts/446033935424448"
}
],
"type": "photo",
"object_id": "446033935424448",
"application": {
"name": "Photos",
"id": "2305272732"
},
"created_time": "2012-05-14T12:59:13+0000",
"updated_time": "2012-05-15T14:19:48+0000",
"likes": {
"data": [
{
"name": "Barbara Fried",
"id": "1336683610"
}
],
"count": 1
},
"comments": {
"data": [
{
"id": "115641638572281_446033935424448_1363348",
"from": {
"name": "Barbara Fried",
"id": "1336683610"
},
"message": "They look like total love dogs!",
"created_time": "2012-05-15T14:19:48+0000"
}
],
"count": 1
}
}
],
"paging": {
"previous": "https://graph.facebook.com/115641638572281/tagged?format=json&limit=2&since=1337067838&__previous=1",
"next": "https://graph.facebook.com/115641638572281/tagged?format=json&limit=2&until=1337000352"
}
}