How can I get a permanent link for pictures in a post? For example, I can get all information about one post:
912163612218997/?fields=picture,full_picture,attachments
{
"picture": "https://scontent.xx.fbcdn.net/v/t1.0-0/s130x130/15390764_10154771322382505_5131571043698309499_n.jpg?oh=de4126b3944deb9fb7fca6b534e5e987&oe=58E45F29",
"full_picture": "https://scontent.xx.fbcdn.net/v/t31.0-8/s720x720/15326300_10154771322382505_5131571043698309499_o.jpg?oh=414291d1c1fbc88988afb887177a03c5&oe=59156F5D",
"id": "189675924467773_912163612218997",
"attachments": {
"data": [
{
"description": ...,
"media": {
"image": {
"height": 372,
"src": "https://scontent.xx.fbcdn.net/v/t31.0-8/s720x720/15326300_10154771322382505_5131571043698309499_o.jpg?oh=414291d1c1fbc88988afb887177a03c5&oe=59156F5D",
"width": 720
}
},
"target": {
"id": "10154771322382505",
"url": "https://www.facebook.com/photo.php?fbid=10154771322382505&set=gm.912163612218997&type=3"
},
"type": "photo",
"url": "https://www.facebook.com/photo.php?fbid=10154771322382505&set=gm.912163612218997&type=3"
}
]
}
}
However, these picture links are temporary. It won't be available after several hours.
Is there any way to get the permanent picture URL from Facebook GraphAPI?
I sort of figure out a workaround using redirect:
Fire graph API using object id and get CDN URL
Redirect to the CDN URL
Basically, as long as we know the object id, we can get the URL. Unfortunately, it is a bit slow.
Related
I'm trying the API Graph explorer, I'd like the photos param to give back the photo url but I can't set it in the GET request which currently is graph.facebook.com/v2.9/me?fields=id,name,photos
"id": "22331427282551006",
"name": "USER",
"photos": {
"data": [
{
"created_time": "2017-07-01T03:36:09+0000",
"id": "85419012312312"
},
{
"created_time": "2016-06-21T04:23:13+0000",
"id": "10112312312312311"
},
{
"created_time": "2016-01-31T13:03:50+0000",
"id": "12207150957211111"
},
{
"created_time": "2014-10-06T04:30:04+0000",
"id": "12312312312312312"
Also tried graph.facebook.com/v2.9/me?fields=id,name,photos?type=uploaded as said in this reference to get uploaded photos with unexpected errors.
You want the content of the images field below the photos edge, so you need to ask for that explicitly as well.
me?fields=id,name,photos{images}
If you need more sub-fields of the photos edge, then you need to include those as well, comma-separated.
https://developers.facebook.com/docs/graph-api/using-graph-api/#fieldexpansion
I have been using Graph API for a while, but I am not able to figure this one out.
I have a group id, from whose feed I want to get the image urls for all available resolutions.
I know I can do that using the 'images' field of a photo id.
Here is a sample code which gets the id
<group-id>/feed?fields=attachments{target{id}}
I tried
<group-id>/feed?fields=attachments{target{id{images}}}
and also this
<group-id>/feed?fields=attachments.fields(target.fields(id{images}))
and this
<group-id>/feed?fields=attachments.fields(target.fields(id.fields(images)))
All of them return the JSON having the id, but not the images details I need.
I hope I have provided enough information.
You can use the below format while calling the API and it will return you with the images URL included in the post
<group-id>/feed?fields=created_time,attachments,message
You will get the response in the below format.
{
"created_time": "2017-11-16T06:21:37+0000",
"id": "543993212434753_1004360179731385",
"attachments": {
"data": [
{
"description": "Best #ethnic wear store for #women.
Shop Now>> sairandhri.com",
"media": {
"image": {
"height": 720,
"src": "https://scontent.xx.fbcdn.net/v/t1.0-9/s720x720/23519069_887109751445971_6170575397465061641_n.jpg?oh=170436ae447ec615f547d700017c67b4&oe=5AA4F844",
"width": 537
}
},
"target": {
"id": "887109751445971",
"url": "https://www.facebook.com/SairandhriShowroom/photos/a.302015823288703.1073741828.300462640110688/887109751445971/?type=3"
},
"type": "photo",
"url": "https://www.facebook.com/SairandhriShowroom/photos/a.302015823288703.1073741828.300462640110688/887109751445971/?type=3"
}
]
}
}
Its working and tested on Graph API Explorer
For example this graph
https://graph.facebook.com/audi/posts?access_token=[ACCESS TOKEN]&fields=id,message,picture,link,name,description,type,icon,created_time,from,object_id&since=2016-10-14T17:54:17+0000&limit=1
will give you this result(after replace ACCESS TOKEN with your access token ) :
{
"data": [
{
"id": "96585976469_10153772437221470",
"message": "Take a night tour of Capitol Hill with the #AudiRS7. #AudiDuel",
"picture": "https://scontent.xx.fbcdn.net/v/t1.0-0/s130x130/14680669_10153772435521470_6025374941796908984_n.jpg?oh=3654e74f79914c9bb0fa596ce8434c46&oe=589E82B4",
"link": "https://www.facebook.com/audi/photos/a.101113351469.101662.96585976469/10153772435521470/?type=3",
"name": "Photos from Audi USA's post",
"type": "photo",
"icon": "https://www.facebook.com/images/icons/photo.gif",
"created_time": "2016-10-14T17:54:17+0000",
"from": {
"name": "Audi USA",
"id": "96585976469"
},
"object_id": "10153772435521470"
}
],
"paging": {
"previous": "https://graph.facebook.com/v2.5/96585976469/posts?fields=id,message,picture,link,name,description,type,icon,created_time,from,object_id&limit=1&since=1476467657&access_token=[ACCESS TOKEN]&__paging_token=[ACCESS TOKEN]&__previous=1",
"next": "https://graph.facebook.com/v2.5/96585976469/posts?fields=id,message,picture,link,name,description,type,icon,created_time,from,object_id&limit=1&since=2016-10-14T17\u00253A54\u00253A17+0000&access_token=[ACCESS TOKEN]&until=1476467657&__paging_token=[ACCESS TOKEN]"
}
}
and this is the link of the post
https://www.facebook.com/audi/posts/10153772437221470
it gave me just the first one photo but I need all photos in this post
attachments is the field you are looking for.
(Seems not officially documented, perhaps because those aggregate posts are special. But Graph API Explorer suggests it as one of the available fields.)
I need to retrieve wall posts from Facebook for a given account, but I'm only interested in posts that contain a photo. Is there a way to add such a filter to a Facebook graph api query? Something like:
https://graph.facebook.com/DigitasLBiNL?fields=feed&type=photo
The facebook data contains a type property which comes back as photo, so I would think this would be possible, but I haven't had any luck going through the facebook sdk documentation or tinkering around.
I know I could do the filtering myself, but I'd prefer to be able to keep the paging property that facebook returns.
The edges
/{user_id}/home (https://developers.facebook.com/docs/graph-api/reference/v2.1/user/home#read)
/{user_id}/feed (https://developers.facebook.com/docs/graph-api/reference/v2.1/user/feed#read)
should (as per documentation) both be able to take a filter paramenter, containing filter keys from the stream_filter FQL table (https://developers.facebook.com/docs/reference/fql/stream_filter/).
If I run the FQL
select name, value, type, filter_key from stream_filter where uid=me()
I get the following result:
{
"data": [
{
"name": "News Feed",
"value": null,
"type": "newsfeed",
"filter_key": "nf"
},
{
"name": "Status Updates",
"value": 2915120374,
"type": "application",
"filter_key": "app_2915120374"
},
{
"name": "Photos",
"value": 2305272732,
"type": "application",
"filter_key": "app_2305272732"
},
{
"name": "Links",
"value": 2309869772,
"type": "application",
"filter_key": "app_2309869772"
},
{
"name": "Pages",
"value": null,
"type": "public_profiles",
"filter_key": "pp"
},
{
"name": "Video",
"value": 2392950137,
"type": "application",
"filter_key": "app_2392950137"
},
{
"name": "Notes",
"value": 2347471856,
"type": "application",
"filter_key": "app_2347471856"
},
{
"name": "Groups",
"value": 2361831622,
"type": "application",
"filter_key": "app_2361831622"
}
]
}
So, if I choose app_2305272732 as filter key for the photos, I am able to run the follwoing Graph API request successfully:
/me/home?filter=app_2305272732&limit=3
This gives me the three most recent photo posts from my newsfeed.
You want to do this for User/Page feeds (Pages are not supported for filtering according to the docs at https://developers.facebook.com/docs/graph-api/reference/v2.1/page/feed#read), so I tried this:
/me/feed?filter=app_2305272732&limit=3
Unfortunately, this doesn't return only photo posts, at least for me. So I think this is a bug in the Facebook Graph API.
According to
https://developers.facebook.com/docs/graph-api/reference/stream-filter/
you can use the type filter with value photo
I am trying to retrieve the "Place" field of a Facebook Graph Post object from a Facebook friend. After obtaining an access token with the friends_status and read_stream permissions, I request from the Graph API like so:
http://graph.facebook.com/[user_id]_[post_id]
What is returned are some of the fields described in the Graph API docs for Post:
{
"id": "1164358582_2458311174854",
"from": {
"name": "Joe Blo",
"id": "1164358582"
},
"message": "Is pretty bummed today",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/1164358582/posts/2458311174854"
},
{
"name": "Like",
"link": "http://www.facebook.com/1164358582/posts/2458311174854"
}
],
"type": "status",
"application": {
"name": "Facebook for Android",
"id": "350685531721"
},
"created_time": "2011-11-20T03:23:04+0000",
"updated_time": "2011-11-20T12:12:49+0000",
"comments": {
"data": [
{
"id": "1164358582_2458311174852_2962531",
"from": {
"name": "Sue Candy",
"id": "1056617421"
},
"message": "OMG I'm so sorry!!!",
"created_time": "2011-11-20T03:25:06+0000"
}
],
"count": 1
}
}
This is all fine and dandy, except for the fact that when I see this Post within my Facebook stream, it also shows a location accompanying the post:
9 hours ago near El Reno, OK
I expected the El Reno, OK Place object returned as a field within this Post, but I don't see it.
In the Facebook Graph API Explorer, I've tried enabling almost every permission and I am not seeing any difference in the response (no "Place" field returned). Am I going about this incorrectly?
Not 100% sure but I think you can only get the "place" info if it is of type "checkin". I totally get where you are coming from, I wondered about that myself.
https://developers.facebook.com/tools/
Try the Graph API Explorer Tool if you haven't already looked at it.