I want to get my statues from facebook api.
for example:
I post a status on my facebook page:
I love apple.
I need to fetch the data.
I used facebook api.
FB.api('/me/feed', function(response)
{
//do my process
}
however, the data I get is in this format
data": [
{
"id": "*",
"from": {
"name": "*",
"id": "*"
},
"story": "* is now friends with \u674e\u7490 and \u9ec4\u68ee\u6d2a.",
"story_tags": {
"0": [
{
"id": "*",
"name": "****",
"offset": 0,
"length": 9,
"type": "user"
}
],
"30": [
{
"id": "100003483506950",
"name": "\u674e\u7490",
"offset": 30,
"length": 2,
"type": "user"
}
],
"37": [
{
"id": "100008056628095",
"name": "\u9ec4\u68ee\u6d2a",
"offset": 37,
"length": 3,
"type": "user"
}
]
},
"privacy": {
"value": ""
},
"type": "status",
"status_type": "approved_friend",
"created_time": "2014-03-23T02:10:33+0000",
"updated_time": "2014-03-23T02:10:33+0000"
},
the things are all about friends approvment, but what I want is my status.
How should I get these information?
Thank you very much.
Chao
The edge {user_id}/feed will return everything that user has done. You can filter down the information returned by adding fields to select what data you want returned.
me/feed?fields=status_type
The status_type argument will return you which type of update it was and you can use that to filter out the updates you don't want.
You can also play around with the arguments at https://developers.facebook.com/tools/explorer/
Related
Back years ago I used the Facebook Graph API to gather users friend photos and likes for those photos. However, that was back when the API was v2.11 or v4 or something like that. Now at version 12, my code no longer works. I've tried getting the same data I once did back using their Graph API but I have no success in doing so.
I have the JSON below to show what data I used to get and which I am now trying to get again. Note that no links within the JSON will work - this is only an example.
Basically Its gathering my friends photos by their ID in ascending order and anyone who has liked those photo.
The call I would normally make to get this data was:
https://graph.facebook.com/[user id]/picture?type=large&width=720&height=720
Are you still able to get other friends photos as well or has that been stopped now? Do your friends have to join your Facebook app in order to gather photo data like this from them?
{
"data": [{
"created_time": "2017-12-08T18:57:53+0000",
"likes": {
"data": [{
"name": "Bill Gates",
"id": "9485030985688759"
}, {
"name": "Bob Barker",
"id": "1944578789965397"
}, {
"name": "Steve Jobs",
"id": "4423564564766486"
}, {
"name": "James Bond",
"id": "1027785445557557"
}, {
"name": "Bart Simpson",
"id": "10214564574448423"
}, {
"name": "Lisa Simpson",
"id": "16845876543328680"
}
],
"paging": {
"cursors": {
"before": "MTAyMHISTeY5MjYyOTE2NzQZD",
"after": "MTUzODUYTREEewQ5OTA2MwZDZD"
}
}
},
"images": [{
"height": 960,
"source": "https:\/\/scontent.xx.fbcdn.net\/v\/t1.0-9\/243633743_10101633995322638_8617605831554312755_n.jpg?oh=d4ca434j6nrn4332d723981a8b3e7137e4&oe=5B044D79",
"width": 720
}, {
"height": 800,
"source": "https:\/\/scontent.xx.fbcdn.net\/v\/t1.0-0\/p600x600\/24909743_10345633995322638_8614363524112755_n.jpg?oh=60e21c107fe171898452tre338a4c918&oe=5B479FB6",
"width": 600
}, {
"height": 640,
"source": "https:\/\/scontent.xx.fbcdn.net\/v\/t1.0-0\/p480x480\/24909743_1013473995322638_861760343422414112755_n.jpg?oh=5302f74db20c780436nGddn16461f70&oe=5Bttr48C",
"width": 480
}
],
"id": "10101633993437538"
}, {
"created_time": "2017-06-05T21:14:28+0000",
"likes": {
"data": [{
"name": "Amy Someone",
"id": "453437546783720"
}, {
"name": "Mike LG",
"id": "181855436553221"
}, {
"name": "Homer Simpson",
"id": "194335643226397"
}, {
"name": "Bart Simpson",
"id": "194332353226397"
}
],
"paging": {
"cursors": {
"before": "MTAyMTMRFeht5zg3MzM3MjAZD",
"after": "MTUzODcfrhreOTQ5OTA2MwZDZD"
}
}
},
"images": [{
"height": 1440,
"source": "https:\/\/scontent.xx.fbcdn.net\/v\/t31.0-8\/18839799_10101467545354528_4346343h5628628521_o.jpg?oh=31297frt35y6e892c0807dad0345b58eb&oe=5B157345",
"width": 800
}, {
"height": 1296,
"source": "https:\/\/scontent.xx.fbcdn.net\/v\/t31.0-8\/p720x720\/18839799_10101417914904528_4346353536428628521_o.jpg?oh=809bb29a5b55e222411a014c8392eea2&oe=5B47D7B8",
"width": 720
}
],
"id": "10134664346528"
}
]
}
As a test I sent my wife a request to be a tester and she approved it but I still can not even pull data from her account?
As you see it just has my friend count and nothing more.
I also made sure it accepted my wife as a tester and it looks like it has:
But that does have a debug message saying:
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!
I queried a page with due permissions for its feed. There was a post with three photos. The response json was:
{
"id": "some_id",
"from": {
"category": "Tv show",
"name": "some_name",
"id": "some_id"
},
"message": "New post with 3 photos",
"picture": "some_link",
"link": "some_link",
"icon": "some_link",
"actions": [
{
"name": "Comment",
"link": "some_link"
},
{
"name": "Like",
"link": "some_link"
}
],
"privacy": {
"description": "Public",
"value": "EVERYONE",
"friends": "",
"networks": "",
"allow": "",
"deny": ""
},
"type": "photo",
"status_type": "mobile_status_update",
"object_id": "some_id",
"created_time": "2014-02-05T07:06:22+0000",
"updated_time": "2014-02-05T07:06:35+0000",
"likes": {
"data": [
{
"id": "some_id",
"name": "some_name"
}
],
"paging": {
"cursors": {
"after": "MTgyNDY2NjQ1MjM4MTc5",
"before": "MTgyNDY2NjQ1MjM4MTc5"
}
}
},
"comments": {
"data": [
{
"id": "some_id",
"from": {
"category": "Tv show",
"name": "some_name",
"id": "some_id"
},
"message": "With a comment and a like on it",
"can_remove": true,
"created_time": "2014-02-05T07:06:35+0000",
"like_count": 0,
"user_likes": false
}
],
"paging": {
"cursors": {
"after": "MQ==",
"before": "MQ=="
}
}
}
},
Firstly, I only got one object_id, whereas the post contained 3 photos. The object_id was of a single photo. I also queried through fql for object_id for that photo in photo table and the object_ids were not matching. Why is it so? What does object_id mean in both cases?
The Object ID for Posts will be different to the Object ID of the photos used in the post, as they are effectively different representations of the same thing. The id will be the ID of the page post, and the object_id will be the Album ID of the uploaded photos.
Try calling /{object_id}/photos to get the list of photos in the post.
A good way to test what each object_id represents is to go to http://www.facebook.com/{object_id} to see where it goes. It will either go to a page, post, album / media set, photo or an error page.
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.
I want to get stats (likes, comments, shares) of a Facebook post. How can I do it?
Url: https://graph.facebook.com/<userid>_<postid> - there is a plenty of information about the wall post.
http://developers.facebook.com/tools/explorer - you can use this tool for testing.
Sample data:
{
"id": "<userid>_<postid>",
"from": {
"name": "User Name",
"id": "<userid>"
},
"message": "playing with graph api",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/<userid>/posts/<postid>"
},
{
"name": "Like",
"link": "http://www.facebook.com/<userid>/posts/<postid>"
}
],
"privacy": {
"description": "Public",
"value": "EVERYONE"
},
"type": "status",
"created_time": "2012-03-14T11:33:14+0000",
"updated_time": "2012-03-14T11:33:14+0000",
"comments": {
"count": 0
},
"is_published": true
}
You should just use https://graph.facebook.com/<postid> if it is a status.
You can get the postid by clicking on the date/time in your feed.
If the type is a comment then you can use
https://graph.facebook.com/<postid>_<commentid>