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

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"
}

Related

In FaceBook Graph API v2.4, how can I include pictures/icons of the posts in the JSON feed?

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

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

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.

Access social readers' posts in a facebook App

How can a facebook app, have access to a social reader's post in the feed? For example, I want to have access to Washington Post's social reader post (when someone else reads an article there and it gets shown up in my news feed) from an app that I am writing. Is it possible to do so, using FQL?
It's easily available in the Graph API (i'll check if it's in FQL)
Basically, either way you'll need to request the user_actions.reads permission from your users. (NB: not user_actions:reads which would be for an app whose namespace is 'reads', for news, music and video apps using the build-in actions there's a special scope)
Then, for the Graph API, just make a call to /USER_ID/news.reads - the response includes the recently read articles from all apps using the built-in 'read' action, example response for my account below:
{
"data": [
{
"id": "REMOVED_ID",
"from": {
"id": "REMOVED_MY_USER_ID",
"name": "REMOVED_MY_NAME"
},
"start_time": "2012-05-10T00:05:10+0000",
"end_time": "2012-05-10T00:05:10+0000",
"publish_time": "2012-05-10T00:05:10+0000",
"application": {
"id": "235586169789578",
"name": "The Independent"
},
"data": {
"article": {
"id": "10150697347986736",
"url": "http://www.independent.co.uk/life-style/food-and-drink/features/the-10-best-scotch-whiskies-1488408.html",
"type": "article",
"title": "The 10 Best Scotch Whiskies"
}
},
"likes": {
"count": 0
},
"comments": {
"count": 0
}
},
.... //more articles

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