I would like to extract the image url of a post from a page stream using facebook FQL, i am able to get the following, however I would prefer to get the link to the normal size image only, I then plan to use java to extract the link, but I would like to first simplify the result.
FQL:
SELECT attachment FROM stream WHERE source_id = 187050104663230 AND type = 247 AND created_time > 1383293228 LIMIT 1
Result of above:
{
"data": [
{
"attachment": {
"media": [
{
"href": "https://www.facebook.com/photo.php?fbid=699393523428883&set=a.190470824321158.46817.187050104663230&type=1&relevant_count=1",
"alt": "",
"type": "photo",
"src": "https://fbcdn-photos-h-a.akamaihd.net/hphotos-ak-prn2/1508634_699393523428883_996610253_s.png",
"photo": {
"aid": "187050104663230_46817",
"pid": "187050104663230_1073741857",
"fbid": 699393523428883,
"owner": 187050104663230,
"index": 1,
"width": 1024,
"height": 393,
"images": [
{
"src": "https://fbcdn-photos-h-a.akamaihd.net/hphotos-ak-prn2/1508634_699393523428883_996610253_s.png",
"width": 130,
"height": 49
},
{
"src": "https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-prn2/s720x720/1508634_699393523428883_996610253_n.png",
"width": 720,
"height": 276
}
]
}
}
],
"name": "",
"caption": "",
"description": "",
"properties": [
],
"icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yz/r/StEh3RhPvjk.gif",
"fb_object_type": "photo",
"fb_object_id": "187050104663230_1073741857"
}
}
]
}
Response received in 528 ms
this is as narrowed down as as i could.
Code:
SELECT attachment.media.photo.images.src FROM stream WHERE source_id = 187050104663230 AND type = 247 AND created_time > 1383293228 LIMIT 1
Result:
{
"data": [
{
"attachment": {
"media": [
{
"photo": {
"images": [
{
"src": "https://fbcdn-photos-h-a.akamaihd.net/hphotos-ak-prn2/1508634_699393523428883_996610253_s.png"
},
{
"src": "https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-prn2/s720x720/1508634_699393523428883_996610253_n.png"
}
]
}
}
]
}
}
]
}
Related
I am facing issue with Hapi Pagination. I want to iterate through all the patients, First I would hit the pater url with _count=200. I see that there are 7344 patients.
http://localhost:8080/smart-pgd-fhir/v2/Patient?_total=accurate&_count=200
Result:
{
"resourceType": "Bundle",
"id": "39e484f7-2159-486a-afc0-b1798d24ec2b",
"meta": {
"lastUpdated": "2022-03-02T11:59:58.286-05:00"
},
"type": "searchset",
"total": 7344,
"link": [
{
"relation": "self",
"url": "http://localhost:8080/smart-pgd-fhir/v2/Patient?_count=200&_total=accurate"
},
{
"relation": "next",
"url": "http://localhost:8080/smart-pgd-fhir/v2?_getpages=39e484f7-2159-486a-afc0-b1798d24ec2b&_getpagesoffset=200&_count=200&_pretty=true&_bundletype=searchset"
}
],<DATA>
After iterating though few pages at _getpagesoffse=2200 I dont see an results. Its return empty.
{
"resourceType": "Bundle",
"id": "39e484f7-2159-486a-afc0-b1798d24ec2b",
"meta": {
"lastUpdated": "2022-03-02T11:59:58.286-05:00"
},
"type": "searchset",
"total": 2200,
"link": [
{
"relation": "self",
"url": "http://localhost:8080/smart-pgd-fhir/v2?_getpages=39e484f7-2159-486a-afc0-b1798d24ec2b&_getpagesoffset=2200&_count=200&_pretty=true&_bundletype=searchset"
}
]
}
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"
}
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.
I have tried Page Messages
with the all the required permission i.e read_mailbox, read_page_mailboxes, etc (all the extended permission)
at length I get tried as
https://graph.facebook.com/456330641095467/conversations?access_token=BAAGgcfpJgfUBAHdKaE6KxMWo4rU6VU7psX7Ip4cLbG1yIvX80fkkTXm3ZApdYHmcISmqfnns1gPYZAHXWD2cXX7nMBcj4AK31uptfqJUjNAGXan1ftOK4Tw3sY1WsZD
but i get response as
{
"error": {
"message": "(#210) Subject must be a page.",
"type": "OAuthException",
"code": 210
}
}
I am unable to find out the issue. Please help.
Just use the access_token of page and you are done
yours output would be like this
{
"data": [
{
"id": "t_id.615971188431960",
"snippet": "ok fine reply on test 5:15",
"updated_time": "2013-04-16T12:15:12+0000",
"message_count": 8,
"tags": {
"data": [
{
"name": "inbox"
},
{
"name": "read"
},
{
"name": "seen"
},
{
"name": "sent"
},
{
"name": "source:web"
}
]
},
"participants": {
"data": [
{
"name": "Pragati Singh",
"email": "100000441901858\u0040facebook.com",
"id": "100000441901858"
},
{
"name": "Devdemo",
"email": "456330641095467\u0040facebook.com",
"id": "456330641095467"
}
]
},
"senders": {
"data": [
{
"name": "Devdemo",
"email": "456330641095467\u0040facebook.com",
"id": "456330641095467"
},
{
"name": "Pragati Singh",
"email": "100000441901858\u0040facebook.com",
"id": "100000441901858"
}
]
},
{
"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