I have been learning how the Facebook Graph API works for a while and managed to get the info out of the "me" , "me/likes" and "me/posts" edges,
My question is in regard to the "me/posts" edge; it retrieves all the posts on the user's wall only not the posts/comments he made on another page and or a friends wall, all i get is a "type": "status" JSON node with no actual "message": "" node in the JSON entry saying "XYZ commented on a status."
Example:
{
"id": "<USER_ID>_<POST_ID>",
"from": {
"id": "<USER_ID>",
"name": "XYZ"
},
"story": "XYZ commented on a status.",
"story_tags": {
"0": [
{
"id": "<USER_ID>",
"name": "XYZ",
"offset": 0,
"length": 3,
"type": "user"
}
]
},
"privacy": {
"value": ""
},
"type": "status",
"created_time": "2014-11-11T22:18:25+0000",
"updated_time": "2014-11-11T22:18:25+0000"
}
As you can see there is no "message": "value" node included in the JSON returned its just informing me that he made a comment but i need the value or the message of that comment !
Now, failed attempts i have gone through so far includes:
1. Requesting <PAGE_ID/FRIEND_ID>/posts: I'm unaware of the
PAGE_ID/FRIEND_ID with the information i have from the previous
JSON.
2. Requesting the <POST_ID> returned: As explained it
doesn't work and for my case a 100% of the time.
So is there an official way to know what the user wrote on fan page or on a comment he made on a friend's public wall through the Facebook Graph API or even the FQL API ?
Thanks.
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/
Facebook doesn't seem interested in fixing this.
There is no official way to do this until Facebook fixes the incomplete data.
Related
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
Moving from FQL to Graph API, I found that the V2.2 Graph API apprequests node returns inconsistent responses.
https://graph.facebook.com/v2.2/<id>/apprequests
sometimes returns JSON with the "from" field and sometimes not.
The correct JSON is:
"application": {
"name": "Myapp",
"namespace": "My NS",
"id": "123456"
},
"created_time": "2015-03-16T19:34:00+0000",
"data": "invite",
"from": {
"id": "111111",
"name": "Sender name"
},
"message": "Come and play!",
"to": {
"id": "99999",
"name": "Recipient"
},
"id": "123_456"
}
However, the "from" field in the JSON is sometimes missing (even when requesting it specifically in the "fields" parameter).
When using FQL, I always get the sender_uid field (with the same app token and same user):
SELECT request_id, app_id, recipient_uid, sender_uid FROM apprequest
WHERE app_id = <appID> and recipient_uid=<FBID>
Can anybody explain the mystery?
Facebook's response after investigating this bug: This is by design. There are certain privacy restrictions on Graph API which didn't apply to the deprecated FQL.
We investigated this on our end and found that this happens when the user blocked the application or completely removed Facebook's third party integration.
I'm developing an application and what I want it to do is:
Post a poto on the user's wall
Get, in realtime, the number of likes that this post will recieve
The first problem I'm having is to get the likes count based on the post-id, this is my photo upload code:
FB.api('/photos', 'post', {
message: $user_submited_string,
url:'http://example/url/image.jpg'
}, function(response){
if (!response || response.error) {
//error handler
} else {
var posted_content_id = response.postid;
console.log(posted_content_id);
})
But when I put this posted_content_id variable into the Open Graph Debugger I won't get the number of likes in return:
{
"id": "1685033176_4107146412059",
"from": {
"name": "João Paulo Apolinário Passos",
"id": "1685033176"
},
"picture": "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-prn1/548929_4107355417284_1018318871_s.jpg",
"link": "https://www.facebook.com/photo.php?fbid=4107355417284&set=a.4107146292056.1073741826.1685033176&type=1&relevant_count=7",
"name": "My Test App Photos",
"icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yz/r/StEh3RhPvjk.gif",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/1685033176/posts/4107146412059"
},
{
"name": "Like",
"link": "https://www.facebook.com/1685033176/posts/4107146412059"
}
],
"privacy": {
"description": "Public",
"value": "EVERYONE",
"friends": "",
"networks": "",
"allow": "",
"deny": ""
},
"type": "photo",
"status_type": "added_photos",
"object_id": "4107355417284",
"application": {
"name": "My Test App",
"id": "178883808932511"
},
"created_time": "2013-04-10T01:20:12+0000",
"updated_time": "2013-04-10T01:20:12+0000"
}
Which does not contain the like count of my picture. So the first question is: how to get the like count of the image that the user inserted?
The second thing is that, after getting the number of likes, I want to rank them. To do that, I thought about storing them into a database and set a cron job to check new posts and update the rank with new posts. When I was looking how to do that I came across the "Realtime Updates" section of the Facebook Developers Documentation. But for me it's not clear if I can get this like count in real time and how. And that is my second question: Can I get the number of likes of an image in realtime, using native "Realtime Updates"? And if that's not possible, how to create my own counter? Extended token and cronjobs?
I'm asking this two questions in one because maybe the second question's anwser is also the first one. And the last thing I need to know: even if it's doable, doing something like that violates on someway Facebook Policies?
This is because you are querying for the Post Id, not the Photo Id.
When you upload the photo, a post is also automatically published on the feed of the user.
To read the Photo id, you must use the response.id property.
In your example the id of the photo is 4107146412059, you can derive it from the post id that is in the form <user-id>_<photo-id>, but don't count on it, since that can change in the future.
Doc on the Photo object in the Graph API documentation
Real time updates:
You can get real time push notification from Facebook when the User feed is updated:
but this would be overkill, since you'll get all the posts to the User feed, not only to your photo. Sadly, I think the only way is to poll for updates.
Other info on Real time updates: Facebook documentation
Currently when I look at my posts via the GraphAPI:
https://graph.facebook.com/me/posts/
Some posts have their "story" parameter truncated like this (note the ... after the word toe,):
{
"id": "xxxxxxxxx_yyyyyyyyyyyyy",
"from": {
"name": "zzzzzz",
"id": "1234567890"
},
"story": "\"those things pivot at the toe,...\" on XYZ's photo.",
"story_tags": {
"39": [
{
"id": 11111,
"name": "XYZ",
"offset": 39,
"length": 22,
"type": "user"
}
]
}
The above is a comment on a photo within facebook, so the graph api ids=http://.... approach that I have seen elsewhere on SO does not work. When I try to pass in the id to the comment table via FQL I get no data returned. I have all the appropriate permissions in the access token.
Overall what I am trying to achieve is a way to get everything a user has written/typed on facebook recently, so I need:
1.status updates - achieving this via:
select time, message from status where uid=me()
2.check ins - still working on this
3.comments on photos or working on other peoples status - still working on this and the reason for this post
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.