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.
Related
I am trying to get facebook page insights using Facebook Graph API, I see some strange numbers in page_cta_clicks_logged_in_total(looks like they are coming in all logged_in metrics)
Following is a sample Insight data from Facebook
{
"name": "page_cta_clicks_logged_in_total",
"period": "day",
"values": [
{
"value": {
"470946356598165": 0,
"156880401338097": 0
},
"end_time": "2017-12-13T08:00:00+0000"
},
{
"value": {
"470946356598165": 0,
"156880401338097": 2
},
"end_time": "2017-12-14T08:00:00+0000"
}
],
"title": "Daily Total CTA click count per Page",
"description": "Daily: Total CTA click count per Page",
"id": "<page_id>/insights/page_cta_clicks_logged_in_total/day"
}
what are the numbers 470946356598165 & 156880401338097
You get these ids with click related metrics (Ex. page_cta_clicks_by_age_gender_logged_in_unique, page_cta_clicks_logged_in_total, page_cta_clicks_logged_in_unique).
These ids are basically ids of the Page Buttons (look at the following image).
You can get the details of the button by doing following API call
https://graph.facebook.com/470946356598165?access_token=[access_token]
i see the following response
{
"id": "470946356598165",
"type": "MESSAGE",
"status": "ACTIVE"
}
You can check the node type of the id, through facebook graph api:
https://graph.facebook.com/470946356598165?metadata=1
https://graph.facebook.com/156880401338097?metadata=1
// response:
{
"id": "470946356598165",
...
"metadata": {
"fields": [
...
],
"type": "pagecalltoaction"
},
}
It gives us hints that the node type is pagecalltoaction, which is Page Call To Action.
See More: How can I know if a node returned from Facebook Graph API is a profile or a page?
I'm very new to Facebook Open Graph. What I want to do is simply when a user opens a webpage, it will send a story to his/her timeline. I have created an "Eat a Meal" action on Open Graph. When I click Get code, I get something like this :
https://graph.facebook.com/me/project:eat?
access_token=ACCESS_TOKEN&
method=POST&
meal=http%3A%2F%2Fsamples.ogp.me%2F325653997592127
When I click on this code, I am redirected to another page. I get an Access Token there and then when I click submit I get something like this :
{
"id": "274655529384281"
}
When I click the id, I get this :
{
"id": "274555552716206",
"from": {
"id": "274673726099999",
"name": "Jason McJason"
},
"start_time": "2014-07-16T14:23:26+0000",
"end_time": "2014-07-16T14:23:26+0000",
"publish_time": "2014-07-16T14:23:26+0000",
"application": {
"name": "Project",
"namespace": "project",
"id": "325123427594834"
},
"data": {
"meal": {
"id": "539535656565608",
"url": "http://samples.ogp.me/325625656562127",
"type": "project:meal",
"title": "Sample Meal"
}
},
"type": "project:eat",
"likes": {
"count": 0,
"can_like": true,
"user_likes": false
},
"comments": {
"count": 0,
"can_comment": true,
"comment_order": "chronological"
}
}
But I don't know what to do with all of this data. I just have a simple HTML page. Where should I put these data? I'm a little lost and Facebook's documentation didn't help much. I'd appreciate if you tell me what to do with these. Thanks.
You need to integrate Facebook JS SDK on your web page.
Read up through this documentation- https://developers.facebook.com/docs/javascript/quickstart/v2.0
The very last example creates a post.
When I get a certain status in "/{status id}" api call, I get the message stripped from the mentions. How can I read the mentions?
Thanks
the field message_tags will give an array of mentioned users/pages in that post
Example:
"message_tags": {
"13": [
{
"id": "92689703737",
"name": "Tumblr",
"type": "page",
"offset": 13,
"length": 6
}
]
}
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
}
}