Facebook Graph API apprequests node doesn't return "from" - facebook

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.

Related

Facebook Graph API Get Comments outside of Wall

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.

How can I get a facebook users photo comments

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

How to get the id of the user that send the request?

In my app there is a MultiFriendSelector to invite friends.
I want that the recipient see in the canvas page the id of the user that has sent the request via MultiFriendSelector.
I need to get the id without using PHP or other server side language, but I can use javascript or fbml for example.
I believe Multifriend selector is a user-user request and a typical request looks the below (from attribute will tell you the request senders information)
{
"id": "REQUEST_OBJECT_ID",
"application": {
"name": "APP_DISPLAY_NAME",
"canvas_name": "APP_NAME", // This is identical to the app namespace
"namespace": "APP_NAMESPACE",
"id": "APP_ID"
},
"from": {
"name": "SENDER_USER_NAME",
"id": "SEND_USER_ID"
},
"message": "Check out this Awesome Request!",
"created_time": "2012-01-24T00:43:22+0000",
"type": "apprequest"
}

How do you retrieve the "Place" field of a Facebook Graph Post object?

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.

How to visuzlize facebook post

I have a post id (obtained from the Graph API), can I generate a URL which will display this post in Facebook's interface?
Seems there should be something like http://facebook.com/viewpost?postid=6666666666 ...
You want to manually construct a permalink given only the post ID?
The Graph API for a post ID returns the URLs the user should go to to comment on or like the post, assuming the viewing user has permission to do so.
Example:
GET http://graph.facebook.com/19292868552_10150189643478553?access_token={access token here}
Snipped some of the fields of the response, but you're looking for 'actions':
{
"id": "19292868552_10150189643478553",
"from": {
"name": "Facebook Platform",
"category": "Product/service",
"id": "19292868552"
},
// removed fields from response
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/19292868552/posts/10150189643478553"
},
{
"name": "Like",
"link": "https://www.facebook.com/19292868552/posts/10150189643478553"
},
{
"name": "Share",
"link": "http://networkedblogs.com/hGWk3?a=share"
}
],
// Snipped rest of response
In general, the format of a permalink seems to be:
https://www.facebook.com/{source id}/posts/{post object id}
(Source ID being the user or page ID where the post is)
You can't definitely reply on that URL format always being the same; the API response should be always accurate though