Facebook Graph API fql query for like count vs direct object lookup - facebook

Why is it that these two queries return different like counts?
1) fql?q... query returns 0 likes
https://graph.facebook.com/fql?q=SELECT+url%2C+normalized_url%2C+share_count%2C+like_count%2C+comment_count%2C+total_count%2C+commentsbox_count%2C+comments_fbid%2C+click_count+FROM+link_stat+WHERE+url%3D%27http%3A%2F%2Fwww.facebook.com%2Fpages%2FLine-And-Circle%2F49561759728%27
returns:
{
"data": [
{
"url": "http://www.facebook.com/pages/Line-And-Circle/49561759728",
"normalized_url": "http://www.facebook.com/pages/Line-And-Circle/49561759728",
"share_count": 0,
"like_count": 0,
"comment_count": 0,
"total_count": 0,
"commentsbox_count": 0,
"comments_fbid": null,
"click_count": 0
}
]
}
2) Direct object query returns 436 likes
https://graph.facebook.com/49561759728
returns:
{
"name": "Line & Circle",
"is_published": true,
"website": "http://lineandcirclemusic.tumblr.com/",
"description": "follow \u0040LineAndCircle",
"about": "Echo Park, Los Angeles via the Midwest, USA. http://lineandcirclemusic.tumblr.com/",
"genre": "Indie/Alternative",
"hometown": "Los Angeles, California",
"current_location": "Los Angeles, California",
"record_label": "White Iris",
"press_contact": "lineandcirclemusic\u0040gmail.com",
"influences": "Richard Neutra, Erik Satie, Lord Byron, Richard Yates, Grace Kelly, Phil Hartman, Bobby Briggs, Denard Robinson, etc.",
"band_interests": "Ice cream, ice fishing, etc.",
"category": "Musician/band",
"id": "49561759728",
"link": "https://www.facebook.com/pages/Line-Circle/49561759728",
"likes": 436,
"cover": {
"cover_id": "10151094140979729",
"source": "http://sphotos-a.xx.fbcdn.net/hphotos-ash4/s720x720/391388_10151094140979729_1992918206_n.jpg",
"offset_y": 31
}
}
In other instances, like for username "newfoundglory", the fql query returns something close to the like count, but it is still different than the direct query.
Why is it that these two queries return different results?

The first graph call returns 0 likes, as expected, because that table is used to track the likes and comments for external urls, not internal pages on facebook.
To get that data, you should be using the page table and query for fan_count -
select page_id, name, page_url, fan_count from page where name = 'Line & Circle'
This returns the expected result -
"data": [
{
"page_id": 49561759728,
"name": "Line & Circle",
"page_url": "https://www.facebook.com/pages/Line-Circle/49561759728",
"fan_count": 436
}
]

graph.facebook.com/49561759728?fields=likes
{
"likes": 637,
"id": "49561759728"
}
i use this link for generate https://developers.facebook.com/tools/explorer/?method=GET&path=agenciadac%3Ffields%3Dlikes

Related

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

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.)

How To Find Out What A User "Liked" Facebook API

I'm currently calling the facebook me/home edge to get the users home feed. In the results I might get an entry like the JSON posted below.
My question is, when I get an entry like that where the user's friend ".. likes a link." How do I find out what link they liked? I'm trying to get the title and URL, but can't seem to figure out how. I've try just about every option using facebook's graph explorer.
Ideally, I would like that information to be returned when I made the /me/home request. I tried adding "attachments" to the fields parameter, but that didn't work.
{
actions=({
link="https://www.facebook.com/10154950234790111/posts/323892414481111";name=Comment;
});
comments={
};
"created_time"="2015-01-02T23:18:16+0000";from={
id=10154950234790453;name="Brian Joe";
};
id="10154950234790453_3238924144862222";
likes={
};
privacy={
value="";
};
story="Brian Joe likes a link.";
"story_tags"={
0=({
id=10154950234790111;
length=14;
name="Brian Joe";
offset=0;
type=user;
});
};
type=status;
"updated_time"="2015-01-02T23:18:16+0000";
}
This is a long standing bug in Facebook, probably older than two years.
https://developers.facebook.com/bugs/648986871793611/
https://developers.facebook.com/bugs/522743067756848/
I and many others have given up trying to repro this for Facebook Support.
You can give it a go if you want by reporting it to https://developers.facebook.com/bugs
Ideally Facebook should be inserting the object target in the story_tags like this
{
"story": "phwd likes Moët & Chandon.",
"story_tags": {
"0": [
{
"id": "13608786",
"name": "phwd",
"offset": 0,
"length": 17,
"type": "user"
}
],
"24": [
{
"id": "38995979792",
"name": "Moët & Chandon",
"offset": 24,
"length": 14,
"type": "page"
}
]
},
"id": "13608786_10101895322580287",
"created_time": "2015-01-03T17:35:51+0000"
},
Where this object
"24": [
{
"id": "38995979792",
"name": "Moët & Chandon",
"offset": 24,
"length": 14,
"type": "page"
}
]
Would instead be something like
"24": [
{
"id": "event_id",
"name": "Name of event",
"offset": 24,
"length": 14,
"type": "event"
}
]
So it ends up really being a feature request.

How can I get the liked photo from a Facebook post with description "XXX liked a photo."?

Using the Facebook graph API I can get a post that looks like this:
{
"id": "774345031_10153960483905032",
"from": {
"id": "774345031",
"name": "Ben Davis"
},
"story": "Ben Davis likes a photo.",
"story_tags": {
"0": [
{
"id": "774345031",
"name": "Ben Davis",
"offset": 0,
"length": 9,
"type": "user"
}
]
},
"privacy": {
"value": ""
},
"type": "status",
"created_time": "2014-03-25T20:47:39+0000",
"updated_time": "2014-03-25T20:47:39+0000"
}
How can I get the mentioned photo?
You could try the following FQL query:
select pid, object_id, images from photo where pid in (select attachment.media.photo.pid from stream where post_id="774345031_10153960483905032")
For sure this is only working for Posts whih contain a photo reference. Be sure to gather the read_stream permission beforehand.

How to get brand-children specific like count on Facebook Graph API?

I'm trying without much success to find how to retrieve the number of LIKES that a specific child page of a brand page in facebook has.
However, even though I can retrieve the the children and their IDs with:
/facebook/global_brand_children
https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=facebook%2Fglobal_brand_children
The /likes still retrieves the GLOBAL number of likes for said global brand, instead of the number of likes for the SPECIFIC child page.
For example when viewing the return from the Facebook Japan page:
{
"about": "Facebook Japanの公式ページです。",
"can_post": true,
"category": "Computers/internet website",
"checkins": 2,
"general_info": "http://www.facebook.com/FacebookJapan",
"is_published": true,
"talking_about_count": 979217,
"username": "FacebookJapan",
"website": "http://www.facebook.com/",
"were_here_count": 0,
"id": "365989369023",
"name": "Facebook",
"link": "https://www.facebook.com/FacebookJapan",
"likes": 142245893,
"cover": {
"cover_id": "10151895032999024",
"source": "https://fbcdn-sphotos-e-a.akamaihd.net/hphotos-ak-ash3/t1/s720x720/282842_10151895032999024_991535057_n.jpg",
"offset_y": 55,
"offset_x": 0
}
}
Anyone got a clue how to approach this?
Thanks!

Facebook FQL: Get group post status photos

I am trying to pull the photos from a user's post within a group. Posts in a group seem to be either created as a 'photo' or 'status'.
I am able to pull the photos from a post within the group when it is created as a 'photo' using this:
SELECT attachment FROM stream WHERE post_id="<postid>"
But if the post was created as a 'status' this query doesn't return any data for the attachment.
Here is an example of a post created as a 'status' and what the results are. No data for attachment (photo) when I know there is a photo that goes with that post.
SELECT attachment, type, message, created_time FROM stream WHERE post_id = '<postid>'
{
"data": [
{
"attachment": {
"description": ""
},
"type": 308,
"message": "Ceramic wall hanging with mirror from Spain (6\"x8\") $5 pickup in SR",
"created_time": 1379101402
}
]
}
Is this a permissions thing or am I just not pulling from the correct table(s) for this type of post?
Thanks
Chris
Just saying that it works fine for me:
SELECT post_id, attachment, type, message, created_time FROM stream WHERE post_id="POST_ID"
POST_ID looking like: 481234567779150_559912345679366. The permissions I use are user_groups and user_friends.
{
"data": [
{
"post_id": "481234567779150_559912345679366",
"attachment": {
"media": [
{
"href": "https://www.facebook.com/photo.php?fbid=10123450&set=gm.5599123456789366&type=1&relevant_count=1",
"alt": "bla bla bla",
"type": "photo",
"src": "https://fbcdn-photos-f-a.akamaihd.net/hphotos-ak-prn1/1013188_102013456789034740_1177097408_s.jpg",
"photo": {
"aid": "65904234567838363",
"pid": "65904345678990795",
"fbid": "10202345678934740",
"owner": 1533245678910,
"index": 1,
"width": 1032,
"height": 581,
"images": [
{
"src": "https://fbcdn-photos-f-a.akamaihd.net/hphotos-ak-prn1/1013188_10123456789_1177097408_s.jpg",
"width": 130,
"height": 73
}
]
}
}
],
"name": "",
"caption": "",
"description": "",
"properties": [
],
"icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yz/r/StEh3RhPvjk.gif",
"fb_object_type": "photo",
"fb_object_id": "65123456789090795"
},
"type": 308,
"message": "bla bla bla",
"created_time": 1373368884
}
]
}
Did you try your query in the Graph API Explorer? Can you give more information? What kind of group is it, secret, public? Is the user one of your friend? I personally tried with both public or private groups and friend or non-friend posts. Can you confirm this happens with other 308-type posts with a photo and on several groups?