How to get Friends uid from tagged photo? - facebook

I can get names from field "text" of table "photo" but
I cant use those names to get uids.
How can I get uids of tagged people in photo??

all you have to do is query the graph api like this :
https://graph.facebook.com/{photo_id} and you will recieve the data you need...
{
"id": "{photo_id}",
"from": {
"name": "{user_that_uploaded_the_photo}",
"id": "123"
},
"tags": {
"data": [
{
"id": "123",
"name": "Lior",
"x": 48.5099,
"y": 37.5276,
"created_time": "2011-10-11T05:50:35+0000"
},
{
"id": "456",
"name": "Shlain",
"x": 19.0397,
"y": 35.3201,
"created_time": "2011-10-11T05:50:40+0000"
},
{
"id": "789",
"name": "Abigail",
"x": 76.8212,
"y": 47.4614,
"created_time": "2011-10-11T05:50:32+0000"
}
...
You can use the graph api explorer to experiment with these methods...
good luck!

Related

Facebook Graph API - getting individual wall posts of a day

I am using Graph Explorer and trying to fetch each individual wall post my friends sent to me on a specific day (my birthday).
My request is for the feed:
https://graph.facebook.com/100000015733365/feed?access_token=xyz&since=7+October+2015
response:
{
"data": [
{
"id": "<post_id_2>",
"from": {
"name": "<name2>",
"id": "<id2>"
},
"story": "<name2> and 69 others wrote on your timeline.",
"story_tags": {
"0": [
{
"id": "<id2>",
"name": "<name2>",
"type": "user",
"offset": 0,
"length": 8
}
],
"37": [
{
"id": "<my_id>",
"name": "<my_name>",
"type": "user",
"offset": 37,
"length": 8
}
],
"13": [
{
"id": "<id3>",
"name": "<name3>",
"type": "user",
"offset": 13,
"length": 9
},
{
"id": "<id4>",
"name": "<name4>",
"type": "user",
"offset": 13,
"length": 9
},
{
"id": "<id5>",
"name": "<name5>",
"type": "user",
"offset": 13,
"length": 9
}
]
},
"privacy": {
"value": "",
"description": "",
"friends": "",
"allow": "",
"deny": ""
},
"type": "status",
"status_type": "wall_post",
"created_time": "2015-10-07T20:43:07+0000",
"updated_time": "2015-10-07T20:43:07+0000",
"is_hidden": false,
"is_expired": false
}
It seems Facebook groups the posts by content, it's okay on my wall (in web browser) but how can I turn off this behavior through the API call?
I cannot find any setting related to this even after I read the API reference thoroughly.
I need these grouped posts one by one because I would like to process them in python, since I cannot achieve this with the graph explorer I think it's okay to not post python code right now.
An alternative would be to expand this 'story' into a list of individual posts but this is well hidden according to the documentation.
Any help is appreciated, thanks!

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

/me/feed in facebook graph api has first comment of wallpost as separate status entry

when getting my feed with /me/feed it seems that the first comment on posts of other users on my wall is represented another time in the feed as an independent status entry (also has a different id) itself.
It looks like the following JSON output. The first entry of the list is apparently generated from the first comment of the second entry of the list.
I could not reproduce the problem, another post on my wall I commented on turned out normal (= no duplicate entry for first comment)
Is this a bug in Facebook itself or can someone explain this behavior?
[
{
"id": "someID_4300357461829",
"from": {
"name": "user1",
"id": "someID"
},
"story": "\"na oida\" on user2's post on your wall.",
"story_tags": {
"13": [
{
"id": "someID2",
"name": "user2",
"offset": 13,
"length": 15,
"type": "user"
}
]
},
"type": "status",
"created_time": "2012-11-03T01:41:15+0000",
"updated_time": "2012-11-03T01:41:15+0000",
"comments": {
"count": 0
}
},
{
"id": "someID_4300356661809",
"from": {
"name": "user2",
"id": "someID2"
},
"to": {
"data": [
{
"name": "user1",
"id": "someID"
}
]
},
"message": "hi!",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/someID/posts/4300356661809"
},
{
"name": "Like",
"link": "https://www.facebook.com/someID/posts/4300356661809"
}
],
"type": "status",
"created_time": "2012-11-03T01:40:54+0000",
"updated_time": "2012-11-03T01:45:21+0000",
"comments": {
"data": [
{
"id": "someID_4300356661809_4479943",
"from": {
"name": "user1",
"id": "someID"
},
"message": "na oida",
"created_time": "2012-11-03T01:41:15+0000"
},
{
"id": "someID_4300356661809_4479949",
"from": {
"name": "user1",
"id": "someID"
},
"message": "interesting",
"created_time": "2012-11-03T01:42:31+0000"
},
{
"id": "someID_4300356661809_4479956",
"from": {
"name": "user1",
"id": "someID"
},
"message": "another one",
"created_time": "2012-11-03T01:44:40+0000"
},
{
"id": "someID_4300356661809_4479959",
"from": {
"name": "user2",
"id": "someID3"
},
"message": "spam",
"created_time": "2012-11-03T01:45:21+0000"
}
],
"count": 4
}
}
]
I had this same issue. I've submitted a bug to facebook. Vote it up - https://developers.facebook.com/bugs/483624361705934
Just in case you haven't realised, those "wrong" posts doesn't have any action in it, so you can filter the right posts just checking if actions exist.

What's the difference between a facebook post.id and status.id?

I am using the graph-api to walk information about a facebook user. In looking at the connections for the User node, both 'posts' and 'statuses' are available.
When walking through the posts, I come across posts of the type 'status' that have slightly different information, than the equivalent status message.
In the example below, you can see that they are the same message, but the "Post Version" has an id of "100002912416196_212493188857760" while the "Status Version" has an id of "212493188857760". Is one "more correct" than the other? Is Facebook in the process of moving from using statuses (and links, etc) to just using posts (or vice versa)? Any help someone could give would be appreciated.
Here's an example (edited to save space)
when called with https://graph.facebook.com/me/posts
"data": [
{
"id": "100002912416196_212493188857760",
"from": {
"name": "Ben Backup",
"id": "100002912416196" },
"to": {
"data": [{
"name": "Dave Upify",
"id": "100001917301370"
}] },
"message": "With Dave Upify",
...
"type": "status",
"created_time": "2012-03-20T20:18:54+0000",
"updated_time": "2012-03-20T20:18:54+0000",
"comments": {
"count": 0
},
"is_published": true
}
when called with https://graph.facebook.com/me/statuses
"data": [{
"id": "212493188857760",
"from": {
"name": "Ben Backup",
"id": "100002912416196" },
"message": "With Dave Upify",
"place": {
"id": "126533127390327",
"name": "Massachusetts Institute of Technology",
"location": {
"street": "77 Massachusetts Avenue",
"city": "Cambridge",
"state": "MA",
"country": "United States",
"zip": "02139",
"latitude": 42.359430693405,
"longitude": -71.092129185382
}
},
"updated_time": "2012-03-20T20:18:52+0000"
},

attributes in facebook graph API

In the facebook Graph API. the actual message of the object appears as "message": or "story":
Example:
{
"id": "148550335191249_236850319694583",
"from": {
"name": "Sinners Highway",
"category": "Musician/band",
"id": "148550335191249"
},
"story": "Sinners Highway edited their Biography and Band Interests.",
"story_tags": {
"0": [
{
"id": 148550335191249,
"name": "Sinners Highway",
"offset": 0,
"length": 15
}
]
},
"type": "status",
"created_time": "2011-09-02T21:49:50+0000",
"updated_time": "2011-09-02T21:49:50+0000",
"comments": {
"count": 0
}
},
and this one:
{
"id": "148550335191249_258570210855927",
"from": {
"name": "Sinners Highway",
"category": "Musician/band",
"id": "148550335191249"
},
"message": "LETS GET ROCKIN'! ",
"picture": "http://platform.ak.fbcdn.net/www/app_full_proxy.php?app=123966167614127&v=1&size=z&cksum=81c39517d99ba86af6a77df2c4879810&src=http\u00253A\u00252F\u00252Fstatic.bandsintown.com\u00252Fimages\u00252Ffacebook\u00252Fpromote\u00252Fnew-date.png",
"link": "http://bnds.in/q0cSbN",
"name": "Sinners Highway \u0040 The Grange in Nottingham, United Kingdom",
"caption": "Sunday, November 27, 2011 at 6:00pm",
"properties": [
{
"name": "Tickets",
"text": "http://bnds.in/nqft0W",
"href": "http://bnds.in/nqft0W"
},
{
"name": "More Tour Dates",
"text": "http://bnds.in/oZ6VTg",
"href": "http://bnds.in/oZ6VTg"
}
],
"type": "link",
"application": {
"name": "Bandsintown",
"canvas_name": "concertsbybit",
"namespace": "concertsbybit",
"id": "123966167614127"
},
"created_time": "2011-10-21T17:44:12+0000",
"updated_time": "2011-10-21T20:01:31+0000",
},
From what I can tell its completely random whether it is a message or a story.
Does anybody know where and when the story attribute is used and why?
Well from those two examples, the noticeable difference is that the story was an activity that was auto-posted about something the band did on facebook (editing their profile), whereas the message was something that someone has posted on the page wall.