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
Related
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
I'm able to get JSON posts feed for a Public Group Page in FaceBook. However, the feed is limited to the following:
{
"data": [
{
"message": "RT Ad Age: Creatives rejoice! The need for speed in digital is putting copy testing under fire http://buff.ly/1NCNUYm",
"created_time": "2015-09-16T19:17:22+0000",
"id": "100893736659527_876911945724365"
},
{
"message": "Smart Design Means Treating Your Users Like Friends.",
"created_time": "2015-09-15T19:17:07+0000",
"id": "100893736659527_876382499110643"
},
{
"message": "Amazon Puts Another Nail in Flash\u2019s Coffin http://buff.ly/1NzwFal (via Digiday)",
"created_time": "2015-09-14T17:25:52+0000",
"id": "100893736659527_875881985827361"
},
{
"message": "Is Belvedere Vodka Good Enough For James Bond?",
"created_time": "2015-09-11T19:17:14+0000",
"id": "100893736659527_874377899311103"
},
{
"message": "RT MailChimp: Our GIPHY integration makes it easy to upload GIFs into your campaign. Exciting, right? http://buff.ly/1JQChqz",
"created_time": "2015-09-10T19:17:14+0000",
"id": "100893736659527_873864092695817"
}
}
I'm able to get the message text, created_time, and id. How can I include pictures/icons of the post?
After #WizKid responded above, this what worked for me: https://graph.facebook.com/v2.4/[page-id]/feed?access_token=[access_token]&fields=picture,id,message
How can a facebook app, have access to a social reader's post in the feed? For example, I want to have access to Washington Post's social reader post (when someone else reads an article there and it gets shown up in my news feed) from an app that I am writing. Is it possible to do so, using FQL?
It's easily available in the Graph API (i'll check if it's in FQL)
Basically, either way you'll need to request the user_actions.reads permission from your users. (NB: not user_actions:reads which would be for an app whose namespace is 'reads', for news, music and video apps using the build-in actions there's a special scope)
Then, for the Graph API, just make a call to /USER_ID/news.reads - the response includes the recently read articles from all apps using the built-in 'read' action, example response for my account below:
{
"data": [
{
"id": "REMOVED_ID",
"from": {
"id": "REMOVED_MY_USER_ID",
"name": "REMOVED_MY_NAME"
},
"start_time": "2012-05-10T00:05:10+0000",
"end_time": "2012-05-10T00:05:10+0000",
"publish_time": "2012-05-10T00:05:10+0000",
"application": {
"id": "235586169789578",
"name": "The Independent"
},
"data": {
"article": {
"id": "10150697347986736",
"url": "http://www.independent.co.uk/life-style/food-and-drink/features/the-10-best-scotch-whiskies-1488408.html",
"type": "article",
"title": "The 10 Best Scotch Whiskies"
}
},
"likes": {
"count": 0
},
"comments": {
"count": 0
}
},
.... //more articles
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.
I've been testing graph API and ran into a problem. How can I get like count from photos of a page/group?
I'm administrator/creator of a group. When entering in https://developers.facebook.com/tools/explorer/ certain photo ID from that group it brings almost all data, even comments, but not the like count. For like part it needs (according to docs) access token despite the fact that anyone can access that info.
How to get access token of my page/group with required permissions and how to use it to get info I need?
If possible I would like to get JSON from a single address if it is possible.
This is possible with a page (even without an access token!) and here's how:
Visit the page on the graph
Get the page's id by going to the page's url:
https://www.facebook.com/pages/platform/19292868552
The number on the end of the URL is the page's id. Take that id and use it with the graph explorer (here) or just visit it directly.
Visit the page's albums
Now appending albums to that url will give you all the albums the page has, including wall photos:
https://graph.facebook.com/19292868552/albums
The output looks like this:
{
"data": [
{
"id": "10150160810478553",
"from": {
"name": "Facebook Platform",
"category": "Product/service",
"id": "19292868552"
},
"name": "Bringing Operation Developer Love to Europe",
"description": "Blog post: http://developers.facebook.com/blog/post/479\n\nVideos and presentations uploaded here: http://developers.facebook.com/videos/",
"location": "Berlin, Paris, London",
"link": "https://www.facebook.com/album.php?fbid=10150160810478553&id=19292868552&aid=285301",
"cover_photo": "10150160811078553",
"count": 32,
"type": "normal",
"created_time": "2011-04-06T23:05:44+0000",
"updated_time": "2011-04-06T23:33:20+0000",
"comments": {
..... etc ....
Selecting an album
For each object in the data array there is an id and a name. Using these two fields you can select the album that contains the photos you want. The first album in this result is "Bringing Operation Developer Love to Europe". Lets look at this albums photos.
Seeing Photos
If you've followed the answer up to this point the next step should be fairly obvious. Use the id for the album you want and append photos to the graph url:
https://graph.facebook.com/10150160810478553/photos
Seeing a Photo's likes
Much like selecting an album, simply use an id in the output of the above step and append likes to the url to see a photos likes:
https://graph.facebook.com/10150160813853553/likes
Output:
{
"data": [
{
"id": "1163036945",
"name": "Aditya Pn"
},
{
"id": "1555885347",
"name": "Nadin M\u00f6ller"
},
{
"id": "100001643068103",
"name": "Umut Ayg\u00fcn"
},
{
"id": "100000165334510",
"name": "Alessandra Milfont"
},
{
"id": "100001472353494",
"name": "Sayer Mohammad Naz"
},
{
"id": "1051008973",
"name": "Jenson Daniel Chambi"
},
{
"id": "100000233515895",
"name": "Ruby Atiga"
},
Using this output you can simply count the number of entries in the data array to get the like count.
Note that all of this is possible from using the graph explorer by clicking on ids in the output box and the connections sidebar (except for the last /likes connection, which will hopefully be added soon. I hope this helps. Also, you do not need an access token to do any of this because pages are public. Hope this helps!
You can get the comments/likes count without having to paginate through all likes by using the fields parameter in combination with likes.limit(1).summary(true). For example, a search api query for pizza below will give you all public posts and their likes count summarized:
https://graph.facebook.com/search?q=pizza&type=post&fields=id,name,likes.limit(1).summary(true)
results (truncated):
{
"data": [
{
"id": "47883936273_659693910762305",
"name": "Instagram",
"created_time": "2014-02-16T01:15:29+0000",
"likes": {
"data": [
{
"id": "100002243084532",
"name": "Yvette Martin"
}
],
"paging": {
"cursors": {
"after": "MTAwMDAyMjQzMDg0NTMy",
"before": "MTAwMDAyMjQzMDg0NTMy"
},
"next": "https://graph.facebook.com/47883936273_659693910762305/likes?limit=1&summary=1&after=MTAwMDAyMjQzMDg0NTMy"
},
"summary": {
"total_count": 13682
}
}
},
{
"id": "136336876521150_314001148754721",
"name": "Pizza Box Turns into Plates & Storage Unit!",
"created_time": "2014-02-15T21:20:00+0000",
"likes": {
"data": [
{
"id": "100005373008864",
"name": "Liliana Campoli"
}
],
"paging": {
"cursors": {
"after": "MTAwMDA1MzczMDA4ODY0",
"before": "MTAwMDA1MzczMDA4ODY0"
},
"next": "https://graph.facebook.com/136336876521150_314001148754721/likes?limit=1&summary=1&after=MTAwMDA1MzczMDA4ODY0"
},
"summary": {
"total_count": 2792
}
}
}
/me/feed returns a LIKES field
I used a solution where I simply find the number of items in the array which display LIKES
Object.keys(item.likes.data).length
This returns the "length" of an object -- which is equal to the number of likes.
http://graph.facebook.com/223766074374957
there is a likes property in the response
{
"name": "Bejeweled Blitz",
"is_published": true,
"website": "https://apps.facebook.com/bejeweledblitz/",
"username": "bejeweledblitz",
"products": "Bejeweled Blitz\nBejeweled\nPlants vs. Zombies\nPeggle\nZuma\nChuzzle\nBookworm Adventures\n \nFor a complete list, please visit www.popcap.com\n ",
"about": "We're the award-winning hit, Bejeweled Blitz! The lightning-fast puzzle game where you have just 60-seconds to match as many gems as you can! Start Blitzing now!",
"general_info": "Speed is the name of the game in Bejeweled Blitz! Bejeweled Blitz is a speedier take on the classic Bejeweled match-3 gem game mechanic. Your goal is to make as many matches as you can in 60-seconds to really make your score soar! But you won't be going it alone! There are special ways to enhance your Bejeweled Blitz game - like Boosts (power-ups like Scrambler, which moves all the gems around the board or +5 seconds, to add 5 seconds more gem-matching time!) and the popular, Rare Gems. Rare Gems are like extra-special power-ups that can REALLY take your game to the next level!",
"talking_about_count": 22487,
"category": "App page",
"id": "223766074374957",
"link": "https://www.facebook.com/bejeweledblitz",
"likes": 5796324,
"cover": {
"cover_id": 383412771743619,
"source": "http://sphotos-c.ak.fbcdn.net/hphotos-ak-ash4/s720x720/417018_383412771743619_1056862875_n.jpg",
"offset_y": 0
}
}